Skip to content

Instantly share code, notes, and snippets.

@appakz
Created April 1, 2013 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save appakz/5282868 to your computer and use it in GitHub Desktop.
Save appakz/5282868 to your computer and use it in GitHub Desktop.
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