// 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
{
///
/// Holds information about the target of a shortcut file.
///
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;
}
///
/// Gets the target product code of the shortcut, or null if not available.
///
public string ProductCode
{
get
{
return this.productCode;
}
}
///
/// Gets the name of the target feature of the shortcut, or null if not available.
///
public string Feature
{
get
{
return this.feature;
}
}
///
/// Gets the target component code of the shortcut, or null if not available.
///
public string ComponentCode
{
get
{
return this.componentCode;
}
}
///
/// Tests whether two shortcut targets have the same product code, feature, and/or component code.
///
/// The first shortcut target to compare.
/// The second shortcut target to compare.
/// True if all parts of the targets are the same, else false.
public static bool operator ==(ShortcutTarget st1, ShortcutTarget st2)
{
return st1.Equals(st2);
}
///
/// Tests whether two shortcut targets have the same product code, feature, and/or component code.
///
/// The first shortcut target to compare.
/// The second shortcut target to compare.
/// True if any parts of the targets are different, else false.
public static bool operator !=(ShortcutTarget st1, ShortcutTarget st2)
{
return !st1.Equals(st2);
}
///
/// Tests whether two shortcut targets have the same product code, feature, and/or component code.
///
/// The shortcut target to compare to the current object.
/// True if is a shortcut target and all parts of the targets are the same, else false.
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;
}
///
/// Generates a hash code using all parts of the shortcut target.
///
/// An integer suitable for hashing the shortcut target.
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);
}
}
}