/// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            unchecked
            {
                if (Types.Length > 16)
                {
                    return(Types.Length.GetHashCode());
                }


                var tReturn = Types.Aggregate(1, (current, type) => (current * 397) ^ type.GetHashCode());

                if (InformalInterface != null)
                {
                    tReturn = InformalInterface.Aggregate(tReturn, (current, type) => (current * 397) ^ type.GetHashCode());
                }
                return(tReturn);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Equalses the specified other.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns></returns>
        public bool Equals(TypeHash other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (InformalInterface != null || other.InformalInterface != null)
            {
                if (InformalInterface == null || other.InformalInterface == null)
                {
                    return(false);
                }

                if (Types.Length != other.Types.Length)
                {
                    return(false);
                }

                var tTypes = Types.SequenceEqual(other.Types);

                if (!tTypes)
                {
                    return(false);
                }

                return(InformalInterface.SequenceEqual(other.InformalInterface));
            }


            return(Types.SequenceEqual(other.Types));
        }