Created
April 1, 2013 02:18
-
-
Save appakz/5282868 to your computer and use it in GitHub Desktop.
Equals and GetHashCode methods for
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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