1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
// 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.
namespace WixToolset.Dtf.WindowsInstaller
{
/// <summary>
/// Holds information about the target of a shortcut file.
/// </summary>
public struct ShortcutTarget
{
private string productCode;
private string feature;
private string componentCode;
internal ShortcutTarget(string productCode, string feature, string componentCode)
{
this.productCode = productCode;
this.feature = feature;
this.componentCode = componentCode;
}
/// <summary>
/// Gets the target product code of the shortcut, or null if not available.
/// </summary>
public string ProductCode
{
get
{
return this.productCode;
}
}
/// <summary>
/// Gets the name of the target feature of the shortcut, or null if not available.
/// </summary>
public string Feature
{
get
{
return this.feature;
}
}
/// <summary>
/// Gets the target component code of the shortcut, or null if not available.
/// </summary>
public string ComponentCode
{
get
{
return this.componentCode;
}
}
/// <summary>
/// Tests whether two shortcut targets have the same product code, feature, and/or component code.
/// </summary>
/// <param name="st1">The first shortcut target to compare.</param>
/// <param name="st2">The second shortcut target to compare.</param>
/// <returns>True if all parts of the targets are the same, else false.</returns>
public static bool operator ==(ShortcutTarget st1, ShortcutTarget st2)
{
return st1.Equals(st2);
}
/// <summary>
/// Tests whether two shortcut targets have the same product code, feature, and/or component code.
/// </summary>
/// <param name="st1">The first shortcut target to compare.</param>
/// <param name="st2">The second shortcut target to compare.</param>
/// <returns>True if any parts of the targets are different, else false.</returns>
public static bool operator !=(ShortcutTarget st1, ShortcutTarget st2)
{
return !st1.Equals(st2);
}
/// <summary>
/// Tests whether two shortcut targets have the same product code, feature, and/or component code.
/// </summary>
/// <param name="obj">The shortcut target to compare to the current object.</param>
/// <returns>True if <paramref name="obj"/> is a shortcut target and all parts of the targets are the same, else false.</returns>
public override bool Equals(object obj)
{
if (obj == null || obj.GetType() != typeof(ShortcutTarget))
{
return false;
}
ShortcutTarget st = (ShortcutTarget) obj;
return this.productCode == st.productCode
&& this.feature == st.feature
&& this.componentCode == st.componentCode;
}
/// <summary>
/// Generates a hash code using all parts of the shortcut target.
/// </summary>
/// <returns>An integer suitable for hashing the shortcut target.</returns>
public override int GetHashCode()
{
return (this.productCode != null ? this.productCode.GetHashCode() : 0)
^ (this.feature != null ? this.feature.GetHashCode() : 0)
^ (this.componentCode != null ? this.componentCode.GetHashCode() : 0);
}
}
}
|