Ejemplo 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 :)
         if (AmountBreakdown != null)
         {
             hashCode = hashCode * 59 + AmountBreakdown.GetHashCode();
         }
         if (Items != null)
         {
             hashCode = hashCode * 59 + Items.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if ShoppingCart instances are equal
        /// </summary>
        /// <param name="other">Instance of ShoppingCart to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ShoppingCart other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AmountBreakdown == other.AmountBreakdown ||
                     AmountBreakdown != null &&
                     AmountBreakdown.SequenceEqual(other.AmountBreakdown)
                     ) &&
                 (
                     Items == other.Items ||
                     Items != null &&
                     Items.SequenceEqual(other.Items)
                 ));
        }