예제 #1
0
        /// <summary>
        /// Provides a representative hash code for objects of this type to spread out distribution
        /// in hash tables.
        /// </summary>
        /// <remarks>Objects which consider themselves to be Equal (a.Equals(b) returns true) are
        /// expected to have the same hash code.  Objects which are not Equal may have the same
        /// hash code, but minimizing such overlaps helps with efficient operation of hash tables.
        /// </remarks>
        /// <returns>
        /// an int representing the hash code calculated for the contents of this object
        /// </returns>
        public override int GetHashCode()
        {
            int myHash = base.GetHashCode(); // Fold in hash code for inherited base type

            myHash ^= (int)Severity;         // Fold in Severity (enum) as an int as its own hash code
            myHash ^= Id.GetHashCode();      // Fold in hash code for GUID
            if (Caption != null)
            {
                myHash ^= Caption.GetHashCode();                  // Fold in hash code for string Caption
            }
            if (Description != null)
            {
                myHash ^= Description.GetHashCode();                      // Fold in hash code for string Caption
            }
            if (Details != null)
            {
                myHash ^= Details.GetHashCode();                  // Fold in hash code for string Caption
            }
            if (LogSystem != null)
            {
                myHash ^= LogSystem.GetHashCode();                    // Fold in hash code for string LogSystem
            }
            if (CategoryName != null)
            {
                myHash ^= CategoryName.GetHashCode();                       // Fold in hash code for string CategoryName
            }
            if (UserName != null)
            {
                myHash ^= UserName.GetHashCode();                   // Fold in hash code for string UserName
            }
            if (MethodName != null)
            {
                myHash ^= MethodName.GetHashCode();                     // Fold in hash code for string MethodName
            }
            if (ClassName != null)
            {
                myHash ^= ClassName.GetHashCode();                    // Fold in hash code for string ClassName
            }
            if (FileName != null)
            {
                myHash ^= FileName.GetHashCode(); // Fold in hash code for string FileName
            }
            myHash ^= LineNumber;                 // Fold in LineNumber int as its own hash code
            myHash ^= ThreadId;                   // Fold in ThreadId int as its own hash code

            // Session member is not used in Equals, so we can't use it in hash calculation!

            return(myHash);
        }