diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-05-11 07:36:37 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-05-11 07:36:37 -0700 |
| commit | 3f583916719eeef598d10a5d4e14ef14f008243b (patch) | |
| tree | 3d528e0ddb5c0550954217c97059d2f19cd6152a /src/dtf/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs | |
| parent | 2e5ab696b8b4666d551b2a0532b95fb7fe6dbe03 (diff) | |
| download | wix-3f583916719eeef598d10a5d4e14ef14f008243b.tar.gz wix-3f583916719eeef598d10a5d4e14ef14f008243b.tar.bz2 wix-3f583916719eeef598d10a5d4e14ef14f008243b.zip | |
Merge Dtf
Diffstat (limited to 'src/dtf/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs')
| -rw-r--r-- | src/dtf/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/src/dtf/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs b/src/dtf/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs new file mode 100644 index 00000000..4c043bf2 --- /dev/null +++ b/src/dtf/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Dtf.WindowsInstaller | ||
| 4 | { | ||
| 5 | /// <summary> | ||
| 6 | /// Holds information about the target of a shortcut file. | ||
| 7 | /// </summary> | ||
| 8 | public struct ShortcutTarget | ||
| 9 | { | ||
| 10 | private string productCode; | ||
| 11 | private string feature; | ||
| 12 | private string componentCode; | ||
| 13 | |||
| 14 | internal ShortcutTarget(string productCode, string feature, string componentCode) | ||
| 15 | { | ||
| 16 | this.productCode = productCode; | ||
| 17 | this.feature = feature; | ||
| 18 | this.componentCode = componentCode; | ||
| 19 | } | ||
| 20 | |||
| 21 | /// <summary> | ||
| 22 | /// Gets the target product code of the shortcut, or null if not available. | ||
| 23 | /// </summary> | ||
| 24 | public string ProductCode | ||
| 25 | { | ||
| 26 | get | ||
| 27 | { | ||
| 28 | return this.productCode; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | /// <summary> | ||
| 33 | /// Gets the name of the target feature of the shortcut, or null if not available. | ||
| 34 | /// </summary> | ||
| 35 | public string Feature | ||
| 36 | { | ||
| 37 | get | ||
| 38 | { | ||
| 39 | return this.feature; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | /// <summary> | ||
| 44 | /// Gets the target component code of the shortcut, or null if not available. | ||
| 45 | /// </summary> | ||
| 46 | public string ComponentCode | ||
| 47 | { | ||
| 48 | get | ||
| 49 | { | ||
| 50 | return this.componentCode; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | /// <summary> | ||
| 55 | /// Tests whether two shortcut targets have the same product code, feature, and/or component code. | ||
| 56 | /// </summary> | ||
| 57 | /// <param name="st1">The first shortcut target to compare.</param> | ||
| 58 | /// <param name="st2">The second shortcut target to compare.</param> | ||
| 59 | /// <returns>True if all parts of the targets are the same, else false.</returns> | ||
| 60 | public static bool operator ==(ShortcutTarget st1, ShortcutTarget st2) | ||
| 61 | { | ||
| 62 | return st1.Equals(st2); | ||
| 63 | } | ||
| 64 | |||
| 65 | /// <summary> | ||
| 66 | /// Tests whether two shortcut targets have the same product code, feature, and/or component code. | ||
| 67 | /// </summary> | ||
| 68 | /// <param name="st1">The first shortcut target to compare.</param> | ||
| 69 | /// <param name="st2">The second shortcut target to compare.</param> | ||
| 70 | /// <returns>True if any parts of the targets are different, else false.</returns> | ||
| 71 | public static bool operator !=(ShortcutTarget st1, ShortcutTarget st2) | ||
| 72 | { | ||
| 73 | return !st1.Equals(st2); | ||
| 74 | } | ||
| 75 | |||
| 76 | /// <summary> | ||
| 77 | /// Tests whether two shortcut targets have the same product code, feature, and/or component code. | ||
| 78 | /// </summary> | ||
| 79 | /// <param name="obj">The shortcut target to compare to the current object.</param> | ||
| 80 | /// <returns>True if <paramref name="obj"/> is a shortcut target and all parts of the targets are the same, else false.</returns> | ||
| 81 | public override bool Equals(object obj) | ||
| 82 | { | ||
| 83 | if (obj == null || obj.GetType() != typeof(ShortcutTarget)) | ||
| 84 | { | ||
| 85 | return false; | ||
| 86 | } | ||
| 87 | ShortcutTarget st = (ShortcutTarget) obj; | ||
| 88 | return this.productCode == st.productCode | ||
| 89 | && this.feature == st.feature | ||
| 90 | && this.componentCode == st.componentCode; | ||
| 91 | } | ||
| 92 | |||
| 93 | /// <summary> | ||
| 94 | /// Generates a hash code using all parts of the shortcut target. | ||
| 95 | /// </summary> | ||
| 96 | /// <returns>An integer suitable for hashing the shortcut target.</returns> | ||
| 97 | public override int GetHashCode() | ||
| 98 | { | ||
| 99 | return (this.productCode != null ? this.productCode.GetHashCode() : 0) | ||
| 100 | ^ (this.feature != null ? this.feature.GetHashCode() : 0) | ||
| 101 | ^ (this.componentCode != null ? this.componentCode.GetHashCode() : 0); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | } | ||
