コード例 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (this.GetHashCode() != obj.GetHashCode())
            {
                return(false);
            }
            System.Diagnostics.Debug.Assert(base.GetType() != typeof(object)); // check base.Equals() if base overides Equals()
            if (!base.Equals(obj))
            {
                return(false);
            }
            DiscountSpecific discount = obj as DiscountSpecific;

            return(this.dataInceput == discount.dataInceput && this.motivDiscount == discount.motivDiscount &&
                   this.durata == discount.durata && this.sumaAditionala == discount.sumaAditionala);
        }
コード例 #2
0
        public override int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            DiscountSpecific temp = obj as DiscountSpecific;

            if (temp != null)
            {
                int baseCompare = base.CompareTo(obj);
                if (baseCompare != 0)
                {
                    return(baseCompare);
                }
                else if (this.sumaAditionala > temp.sumaAditionala)
                {
                    return(1);
                }
                else if (this.sumaAditionala < temp.sumaAditionala)
                {
                    return(-1);
                }
                else if (this.dataInceput + this.durata > temp.dataInceput + temp.durata)
                {
                    return(1);
                }
                else if (this.dataInceput + this.durata < temp.dataInceput + temp.durata)
                {
                    return(-1);
                }
                else
                {
                    return(this.motivDiscount.CompareTo(temp.motivDiscount));
                }
            }
            else
            {
                throw new ArgumentException("Object is not a " + this.GetType().ToString());
            }
        }