/// <summary> /// Returns a hash code for this element. /// </summary> /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns> /// <remarks>This method creates the hash code by reflecting the value of all public properties.</remarks> public virtual int GetElementHashCode() { // Get the values of all properties in the object (this is slow, any better ideas?) var propertyValues = this.GetType().GetProperties().Select(pi => pi.GetValue(this, null)); return(HashCodeBuilder.GetHashCode(propertyValues)); }
/// <summary> /// Returns a hash code for this element. /// </summary> /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns> /// <remarks>This method creates the hash code by reflecting the value of all public properties.</remarks> public virtual int GetElementHashCode() { // Get the values of all properties in the object (this is slow, any better ideas?) var properties = this.GetType().GetRuntimeProperties().Where(pi => pi.GetMethod.IsPublic && !pi.GetMethod.IsStatic); var propertyValues = properties.Select(pi => pi.GetValue(this, null)); return(HashCodeBuilder.GetHashCode(propertyValues)); }
/// <summary> /// Returns a hash code for this element. /// </summary> /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns> /// <remarks>This method creates the hash code by reflecting the value of all public properties.</remarks> public virtual int GetElementHashCode() { // Get the values of all properties in the object (this is slow, any better ideas?) #if UNIVERSAL var properties = this.GetType().GetRuntimeProperties().Where(pi => pi.GetMethod.IsPublic && !pi.GetMethod.IsStatic); #else var properties = this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); #endif var propertyValues = properties.Select(pi => pi.GetValue(this, null)); return(HashCodeBuilder.GetHashCode(propertyValues)); }
/// <summary> /// Returns a hash code for this element. /// </summary> /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns> /// <remarks>This method creates the hash code by reflecting the value of all public properties.</remarks> public virtual int GetElementHashCode() { return(HashCodeBuilder.GetHashCode(from pi in base.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public) select pi.GetValue(this, null))); }