public override int GetHashCode() { unchecked { var signatureProperties = GetSignatureProperties(); // 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 var hashCode = UnproxiedType.GetHashCode(); var propertyInfos = signatureProperties as PropertyInfo[] ?? signatureProperties.ToArray(); hashCode = propertyInfos.Select(property => property.GetValue(this, null)) .Where(value => value != null) .Aggregate(hashCode, (current, value) => (current * Constants.HashMultiplier) ^ value.GetHashCode()); // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode return(propertyInfos.Any() ? hashCode : base.GetHashCode()); } }
/// <summary> /// Returns the properties of the current type /// </summary> protected virtual IEnumerable <PropertyInfo> GetTypeProperties() { return(UnproxiedType.GetProperties()); }
/// <summary> /// Returns the type properties of the current instance /// </summary> protected override IEnumerable <PropertyInfo> GetTypeProperties() { return(UnproxiedType.GetProperties() .Where(x => x != null && x.HasAttribute <DomainSignatureAttribute>() && !x.GetIndexParameters().Any())); }