Esempio n. 1
0
        public override int GetHashCode()
        {
            unchecked
            {
                // Choose large primes to avoid hashing collisions
                const int HashingBase       = (int)2166136261;
                const int HashingMultiplier = 16777619;

                int hash = HashingBase;
                hash = (hash * HashingMultiplier) ^ ByteProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ ShortByteProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ IntProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ UIntProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ ShortProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ UShortProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ LongProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ ULongProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ FloatPropertyOne.GetHashCode();
                hash = (hash * HashingMultiplier) ^ FloatPropertyTwo.GetHashCode();
                hash = (hash * HashingMultiplier) ^ DoublePropertyOne.GetHashCode();
                hash = (hash * HashingMultiplier) ^ DoublePropertyTwo.GetHashCode();
                hash = (hash * HashingMultiplier) ^ CharProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ BoolProperty.GetHashCode();
                hash = (hash * HashingMultiplier) ^ DecimalProperty.GetHashCode();
                return(hash);
            }
        }
Esempio n. 2
0
            public override int GetHashCode()
            {
                int hash = 1;

                hash = hash * 17 + IntProperty.GetHashCode();
                hash = hash * 31 + StringProperty.GetHashCode();
                if (ChildrenProperty != null)
                {
                    hash = ChildrenProperty.Aggregate(hash, (current, someValueClass) => current * 13 + someValueClass.GetHashCode());
                }
                return(hash);
            }