コード例 #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 (SessionProfitLoss != null)
                {
                    hashCode = hashCode * 59 + SessionProfitLoss.GetHashCode();
                }
                if (MarkPrice != null)
                {
                    hashCode = hashCode * 59 + MarkPrice.GetHashCode();
                }
                if (Funding != null)
                {
                    hashCode = hashCode * 59 + Funding.GetHashCode();
                }
                if (Socialized != null)
                {
                    hashCode = hashCode * 59 + Socialized.GetHashCode();
                }
                if (SessionBankrupcy != null)
                {
                    hashCode = hashCode * 59 + SessionBankrupcy.GetHashCode();
                }
                if (Timestamp != null)
                {
                    hashCode = hashCode * 59 + Timestamp.GetHashCode();
                }
                if (ProfitLoss != null)
                {
                    hashCode = hashCode * 59 + ProfitLoss.GetHashCode();
                }
                if (Funded != null)
                {
                    hashCode = hashCode * 59 + Funded.GetHashCode();
                }
                if (IndexPrice != null)
                {
                    hashCode = hashCode * 59 + IndexPrice.GetHashCode();
                }
                if (SessionTax != null)
                {
                    hashCode = hashCode * 59 + SessionTax.GetHashCode();
                }
                if (SessionTaxRate != null)
                {
                    hashCode = hashCode * 59 + SessionTaxRate.GetHashCode();
                }
                if (InstrumentName != null)
                {
                    hashCode = hashCode * 59 + InstrumentName.GetHashCode();
                }
                if (Position != null)
                {
                    hashCode = hashCode * 59 + Position.GetHashCode();
                }

                hashCode = hashCode * 59 + Type.GetHashCode();
                return(hashCode);
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns true if Settlement instances are equal
        /// </summary>
        /// <param name="other">Instance of Settlement to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Settlement other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     SessionProfitLoss == other.SessionProfitLoss ||
                     SessionProfitLoss != null &&
                     SessionProfitLoss.Equals(other.SessionProfitLoss)
                     ) &&
                 (
                     MarkPrice == other.MarkPrice ||
                     MarkPrice != null &&
                     MarkPrice.Equals(other.MarkPrice)
                 ) &&
                 (
                     Funding == other.Funding ||
                     Funding != null &&
                     Funding.Equals(other.Funding)
                 ) &&
                 (
                     Socialized == other.Socialized ||
                     Socialized != null &&
                     Socialized.Equals(other.Socialized)
                 ) &&
                 (
                     SessionBankrupcy == other.SessionBankrupcy ||
                     SessionBankrupcy != null &&
                     SessionBankrupcy.Equals(other.SessionBankrupcy)
                 ) &&
                 (
                     Timestamp == other.Timestamp ||
                     Timestamp != null &&
                     Timestamp.Equals(other.Timestamp)
                 ) &&
                 (
                     ProfitLoss == other.ProfitLoss ||
                     ProfitLoss != null &&
                     ProfitLoss.Equals(other.ProfitLoss)
                 ) &&
                 (
                     Funded == other.Funded ||
                     Funded != null &&
                     Funded.Equals(other.Funded)
                 ) &&
                 (
                     IndexPrice == other.IndexPrice ||
                     IndexPrice != null &&
                     IndexPrice.Equals(other.IndexPrice)
                 ) &&
                 (
                     SessionTax == other.SessionTax ||
                     SessionTax != null &&
                     SessionTax.Equals(other.SessionTax)
                 ) &&
                 (
                     SessionTaxRate == other.SessionTaxRate ||
                     SessionTaxRate != null &&
                     SessionTaxRate.Equals(other.SessionTaxRate)
                 ) &&
                 (
                     InstrumentName == other.InstrumentName ||
                     InstrumentName != null &&
                     InstrumentName.Equals(other.InstrumentName)
                 ) &&
                 (
                     Position == other.Position ||
                     Position != null &&
                     Position.Equals(other.Position)
                 ) &&
                 (
                     Type == other.Type ||

                     Type.Equals(other.Type)
                 ));
        }