Exemple #1
0
        /// <summary>
        /// Returns the hashcode for this <see cref="QueryGroup"/>.
        /// </summary>
        /// <returns>The hashcode value.</returns>
        public override int GetHashCode()
        {
            // Make sure to check if this is already taken
            if (!ReferenceEquals(null, m_hashCode))
            {
                return(m_hashCode.Value);
            }

            // Set the default value (should not be nullable for better performance)
            var hashCode = 0;

            // Iterates the child query field
            if (!ReferenceEquals(null, QueryFields))
            {
                foreach (var queryField in QueryFields)
                {
                    hashCode += queryField.GetHashCode();
                }
            }

            // Iterates the child query groups
            if (!ReferenceEquals(null, QueryGroups))
            {
                foreach (var queryGroup in QueryGroups)
                {
                    hashCode += queryGroup.GetHashCode();
                }
            }

            // Set with conjunction
            hashCode += Conjunction.GetHashCode();

            // Set back the hashcode value
            m_hashCode = hashCode;

            // Return the actual hash code
            return(hashCode);
        }