Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Equals and GetHashCode methods for
namespace Microsoft.Tools.ServiceModel
{
/// <summary>
/// Partial class / struct implementation for doing proper Equals behavior of the CFContactSerializerInfo struct
/// so that it can be properly used in the Dictionary in the CFClientBase.
/// </summary>
/// <typeparam name="TChannel"></typeparam>
public partial class CFClientBase<TChannel>
where TChannel : class
{
protected partial struct CFContractSerializerInfo
{
/// <summary>
/// Equality check that compares the 'MessageContractType' to determine whether or not the instances are the same.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object obj)
{
if (obj is CFContractSerializerInfo)
{
return (this.MessageContractType == ((CFContractSerializerInfo)obj).MessageContractType);
}
return false;
}
/// <summary>
/// Hash code based on the MessageContractType
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
if ((MessageContractType != null))
{
return MessageContractType.GetHashCode();
}
else
{
return base.GetHashCode();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.