Esempio n. 1
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)

                hashCode = hashCode * 59 + Years.GetHashCode();

                hashCode = hashCode * 59 + Months.GetHashCode();

                hashCode = hashCode * 59 + Days.GetHashCode();

                hashCode = hashCode * 59 + Hours.GetHashCode();

                hashCode = hashCode * 59 + Minutes.GetHashCode();

                hashCode = hashCode * 59 + Milliseconds.GetHashCode();

                hashCode = hashCode * 59 + TotalYears.GetHashCode();

                hashCode = hashCode * 59 + TotalMonths.GetHashCode();

                hashCode = hashCode * 59 + TotalDays.GetHashCode();

                hashCode = hashCode * 59 + TotalHours.GetHashCode();

                hashCode = hashCode * 59 + TotalMinutes.GetHashCode();

                hashCode = hashCode * 59 + TotalSeconds.GetHashCode();

                hashCode = hashCode * 59 + TotalMilliseconds.GetHashCode();

                hashCode = hashCode * 59 + Ticks.GetHashCode();
                return(hashCode);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Returns true if OutputDateDifference instances are equal
        /// </summary>
        /// <param name="other">Instance of OutputDateDifference to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OutputDateDifference other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Years == other.Years ||

                     Years.Equals(other.Years)
                     ) &&
                 (
                     Months == other.Months ||

                     Months.Equals(other.Months)
                 ) &&
                 (
                     Days == other.Days ||

                     Days.Equals(other.Days)
                 ) &&
                 (
                     Hours == other.Hours ||

                     Hours.Equals(other.Hours)
                 ) &&
                 (
                     Minutes == other.Minutes ||

                     Minutes.Equals(other.Minutes)
                 ) &&
                 (
                     Milliseconds == other.Milliseconds ||

                     Milliseconds.Equals(other.Milliseconds)
                 ) &&
                 (
                     TotalYears == other.TotalYears ||

                     TotalYears.Equals(other.TotalYears)
                 ) &&
                 (
                     TotalMonths == other.TotalMonths ||

                     TotalMonths.Equals(other.TotalMonths)
                 ) &&
                 (
                     TotalDays == other.TotalDays ||

                     TotalDays.Equals(other.TotalDays)
                 ) &&
                 (
                     TotalHours == other.TotalHours ||

                     TotalHours.Equals(other.TotalHours)
                 ) &&
                 (
                     TotalMinutes == other.TotalMinutes ||

                     TotalMinutes.Equals(other.TotalMinutes)
                 ) &&
                 (
                     TotalSeconds == other.TotalSeconds ||

                     TotalSeconds.Equals(other.TotalSeconds)
                 ) &&
                 (
                     TotalMilliseconds == other.TotalMilliseconds ||

                     TotalMilliseconds.Equals(other.TotalMilliseconds)
                 ) &&
                 (
                     Ticks == other.Ticks ||

                     Ticks.Equals(other.Ticks)
                 ));
        }