예제 #1
0
파일: TimeRecord.cs 프로젝트: rstens/hets
        /// <summary>
        /// Returns true if TimeRecord instances are equal
        /// </summary>
        /// <param name="other">Instance of TimeRecord to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TimeRecord other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     RentalAgreement == other.RentalAgreement ||
                     RentalAgreement != null &&
                     RentalAgreement.Equals(other.RentalAgreement)
                 ) &&
                 (
                     WorkedDate == other.WorkedDate ||
                     WorkedDate.Equals(other.WorkedDate)
                 ) &&
                 (
                     Hours == other.Hours ||
                     Hours != null &&
                     Hours.Equals(other.Hours)
                 ) &&
                 (
                     RentalAgreementRate == other.RentalAgreementRate ||
                     RentalAgreementRate != null &&
                     RentalAgreementRate.Equals(other.RentalAgreementRate)
                 ) &&
                 (
                     EnteredDate == other.EnteredDate ||
                     EnteredDate != null &&
                     EnteredDate.Equals(other.EnteredDate)
                 ) &&
                 (
                     TimePeriod == other.TimePeriod ||
                     TimePeriod != null &&
                     TimePeriod.Equals(other.TimePeriod)
                 ));
        }
예제 #2
0
파일: TimeRecord.cs 프로젝트: rstens/hets
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;

                // Suitable nullity checks
                hash = hash * 59 + Id.GetHashCode();

                if (RentalAgreement != null)
                {
                    hash = hash * 59 + RentalAgreement.GetHashCode();
                }

                hash = hash * 59 + WorkedDate.GetHashCode();

                if (Hours != null)
                {
                    hash = hash * 59 + Hours.GetHashCode();
                }

                if (RentalAgreementRate != null)
                {
                    hash = hash * 59 + RentalAgreementRate.GetHashCode();
                }

                if (EnteredDate != null)
                {
                    hash = hash * 59 + EnteredDate.GetHashCode();
                }

                if (TimePeriod != null)
                {
                    hash = hash * 59 + TimePeriod.GetHashCode();
                }

                return(hash);
            }
        }