using System; using System.Runtime.Serialization; namespace Tanshu.Accounts.Contracts { public class BillItemKey { //Old = 0, New = 1, Modifiers = 2+ public BillItemKey(int ProductID, bool IsNew) { this.ProductID = ProductID; this.IsNew = IsNew; } public int ProductID { get; private set; } public bool IsNew { get; private set; } public override int GetHashCode() { return ProductID.GetHashCode() ^ IsNew.GetHashCode(); } public override bool Equals(object obj) { if (obj is BillItemKey) return (this == (BillItemKey)obj); else return false; } public override string ToString() { return string.Format("{0} - {1}", ProductID, IsNew); } public static bool operator ==(BillItemKey a, BillItemKey b) { if (object.ReferenceEquals(null, a)) return object.ReferenceEquals(null, b); if (!(a is BillItemKey)) return false; if (!(b is BillItemKey)) return false; return a.ProductID == b.ProductID && a.IsNew == b.IsNew; } public static bool operator !=(BillItemKey a, BillItemKey b) { return !(a == b); } } }