Пример #1
0
 public override int GetHashCode()
 {
     unchecked {
         const int randomPrime = 397;
         int       hashCode    = Id.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (FullDocumentFileName != null ? FullDocumentFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (FreeSnippetFileName != null ? FreeSnippetFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (OriginalFileName != null ? OriginalFileName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Degree != null ? Degree.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (CourseName != null ? CourseName.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (CourseCode != null ? CourseCode.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Year != null ? Year.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ UniversityId.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ UploadedBy.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ UploadedAt.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (DeletedAt != null ? DeletedAt.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ IsFree.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (IsApproved != null ? IsApproved.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Hash != null ? Hash.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (MinHashSignature != null ? MinHashSignature.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ CategoryId.GetHashCode();
         return(hashCode);
     }
 }
        /// <summary>
        /// Получение хэша для группировки допуслуг.
        /// Группировка производится относительноп пассажира и данных допуслуги
        /// </summary>
        /// <returns>Хэш группировки</returns>
        public int ComputeGroupingHashCode()
        {
            // Если в клиентском коде не была указана ссылка на пассажира, заваливаем вычесление
            // т.к. без указания ссылки на пассажира хэш не будет валидным
            if (TravellerRef.Count == 0)
            {
                throw new ArgumentException("TravellerRef");
            }

            if (Name == null)
            {
                throw new ArgumentException("Name");
            }

            if (RFIC == null)
            {
                throw new ArgumentException("RFIC");
            }

            if (RFISC == null)
            {
                throw new ArgumentException("RFISC");
            }

            if (CompanyCode == null)
            {
                throw new ArgumentException("CompanyCode");
            }

            unchecked
            {
                var hash =
                    TravellerRef[0] +
                    Name.GetHashCode() +
                    RFIC.GetHashCode() +
                    RFISC.GetHashCode() +
                    IsFree.GetHashCode() +
                    Status.GetHashCode() +
                    CompanyCode.GetHashCode();

                if (SSRCode != null)
                {
                    hash += SSRCode.GetHashCode();
                }

                if (SSRText != null)
                {
                    hash += SSRText.GetHashCode();
                }

                if (TypeCode != null)
                {
                    hash += TypeCode.GetHashCode();
                }

                return(hash);
            }
        }