narsil/Tanshu.Accounts.Contracts/Data Contracts Display/BillItemKey.cs

52 lines
1.4 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
public class BillItemKey
{
//Old = 0, New = 1, Modifiers = 2+
public BillItemKey(int ProductID, int KotID)
2010-03-02 17:56:21 +00:00
{
this.ProductID = ProductID;
this.KotID = KotID;
2010-03-02 17:56:21 +00:00
}
public int ProductID { get; private set; }
public int KotID { get; private set; }
2010-03-02 17:56:21 +00:00
public override int GetHashCode()
{
return ProductID.GetHashCode() ^ KotID.GetHashCode();
2010-03-02 17:56:21 +00:00
}
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, KotID);
2010-03-02 17:56:21 +00:00
}
public static bool operator ==(BillItemKey a, BillItemKey b)
{
if (object.ReferenceEquals(null, a))
return object.ReferenceEquals(null, b);
2010-03-02 17:56:21 +00:00
if (!(a is BillItemKey))
return false;
if (!(b is BillItemKey))
return false;
return a.ProductID == b.ProductID && a.KotID == b.KotID;
2010-03-02 17:56:21 +00:00
}
public static bool operator !=(BillItemKey a, BillItemKey b)
{
return !(a == b);
}
}
}