public override int GetHashCode()
{
unchecked
{
PropertyInfo[] signatureProperties = this.GetSignatureProperties();
// If no properties were flagged as being part of the signature of the object,
// then simply return the hashcode of the base object as the hashcode.
if (signatureProperties.Length == 0)
{
// ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode
return base.GetHashCode();
}
// It's possible for two objects to return the same hash code based on
// identically valued properties, even if they're of two different types,
// so we include the object's type in the hash calculation
int hashCode = this.GetType().GetHashCode();
for (var i = 0; i < signatureProperties.Length; i++)
{
PropertyInfo property = signatureProperties[i];
object value = property.GetValue(this, null);
if (value != null)
{
hashCode = (hashCode * HashMultiplier) ^ value.GetHashCode();
}
}
return hashCode;
}
}