コード例 #1
0
ファイル: Trip.cs プロジェクト: gplumb/CertainSix
 /// <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 :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         hashCode = hashCode * 59 + ContainerCount.GetHashCode();
         hashCode = hashCode * 59 + MaxTemperature.GetHashCode();
         hashCode = hashCode * 59 + MeanTemperature.GetHashCode();
         hashCode = hashCode * 59 + SpoiledContainerCount.GetHashCode();
         hashCode = hashCode * 59 + SpoiledProductCount.GetHashCode();
         return(hashCode);
     }
 }
コード例 #2
0
ファイル: Trip.cs プロジェクト: gplumb/CertainSix
        /// <summary>
        /// Returns true if Trip instances are equal
        /// </summary>
        /// <param name="other">Instance of Trip to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Trip other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     ContainerCount == other.ContainerCount ||
                     ContainerCount.Equals(other.ContainerCount)
                 ) &&
                 (
                     MaxTemperature == other.MaxTemperature ||
                     MaxTemperature.Equals(other.MaxTemperature)
                 ) &&
                 (
                     MeanTemperature == other.MeanTemperature ||
                     MeanTemperature.Equals(other.MeanTemperature)
                 ) &&
                 (
                     SpoiledContainerCount == other.SpoiledContainerCount ||
                     SpoiledContainerCount.Equals(other.SpoiledContainerCount)
                 ) &&
                 (
                     SpoiledProductCount == other.SpoiledProductCount ||
                     SpoiledProductCount.Equals(other.SpoiledProductCount)
                 ));
        }