예제 #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 :)
         if (ProductPhotoID != null)
         {
             hashCode = hashCode * 59 + ProductPhotoID.GetHashCode();
         }
         if (ThumbNailPhoto != null)
         {
             hashCode = hashCode * 59 + ThumbNailPhoto.GetHashCode();
         }
         if (ThumbNailPhotoFileName != null)
         {
             hashCode = hashCode * 59 + ThumbNailPhotoFileName.GetHashCode();
         }
         if (LargePhoto != null)
         {
             hashCode = hashCode * 59 + LargePhoto.GetHashCode();
         }
         if (LargePhotoFileName != null)
         {
             hashCode = hashCode * 59 + LargePhotoFileName.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            Photo largePizza = new LargePhoto("fromurl", "tourl");

            largePizza = new Cheese(largePizza);
            largePizza = new Peppers(largePizza);

            Console.WriteLine(string.Format("{0},{1}", largePizza.GetName(), largePizza.CalCulateCost()));
            Console.ReadKey(true);
        }
예제 #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (LargePhoto == null ? 0 : LargePhoto.GetHashCode());
         hash = hash * 23 + (LargePhotoFileName == null ? 0 : LargePhotoFileName.GetHashCode());
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (ThumbNailPhoto == null ? 0 : ThumbNailPhoto.GetHashCode());
         hash = hash * 23 + (ThumbnailPhotoFileName == null ? 0 : ThumbnailPhotoFileName.GetHashCode());
         return(hash);
     }
 }
예제 #4
0
        /// <summary>
        /// Returns true if ProductPhoto instances are equal
        /// </summary>
        /// <param name="other">Instance of ProductPhoto to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ProductPhoto other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ProductPhotoID == other.ProductPhotoID ||
                     ProductPhotoID != null &&
                     ProductPhotoID.Equals(other.ProductPhotoID)
                     ) &&
                 (
                     ThumbNailPhoto == other.ThumbNailPhoto ||
                     ThumbNailPhoto != null &&
                     ThumbNailPhoto.Equals(other.ThumbNailPhoto)
                 ) &&
                 (
                     ThumbNailPhotoFileName == other.ThumbNailPhotoFileName ||
                     ThumbNailPhotoFileName != null &&
                     ThumbNailPhotoFileName.Equals(other.ThumbNailPhotoFileName)
                 ) &&
                 (
                     LargePhoto == other.LargePhoto ||
                     LargePhoto != null &&
                     LargePhoto.Equals(other.LargePhoto)
                 ) &&
                 (
                     LargePhotoFileName == other.LargePhotoFileName ||
                     LargePhotoFileName != null &&
                     LargePhotoFileName.Equals(other.LargePhotoFileName)
                 ));
        }