Exemplo 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 :)

                hashCode = hashCode * 59 + QuoteCurrency.GetHashCode();

                hashCode = hashCode * 59 + Kind.GetHashCode();
                if (TickSize != null)
                {
                    hashCode = hashCode * 59 + TickSize.GetHashCode();
                }
                if (ContractSize != null)
                {
                    hashCode = hashCode * 59 + ContractSize.GetHashCode();
                }
                if (IsActive != null)
                {
                    hashCode = hashCode * 59 + IsActive.GetHashCode();
                }

                hashCode = hashCode * 59 + OptionType.GetHashCode();
                if (MinTradeAmount != null)
                {
                    hashCode = hashCode * 59 + MinTradeAmount.GetHashCode();
                }
                if (InstrumentName != null)
                {
                    hashCode = hashCode * 59 + InstrumentName.GetHashCode();
                }

                hashCode = hashCode * 59 + SettlementPeriod.GetHashCode();
                if (Strike != null)
                {
                    hashCode = hashCode * 59 + Strike.GetHashCode();
                }

                hashCode = hashCode * 59 + BaseCurrency.GetHashCode();
                if (CreationTimestamp != null)
                {
                    hashCode = hashCode * 59 + CreationTimestamp.GetHashCode();
                }
                if (ExpirationTimestamp != null)
                {
                    hashCode = hashCode * 59 + ExpirationTimestamp.GetHashCode();
                }
                return(hashCode);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns true if Instrument instances are equal
        /// </summary>
        /// <param name="other">Instance of Instrument to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Instrument other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     QuoteCurrency == other.QuoteCurrency ||

                     QuoteCurrency.Equals(other.QuoteCurrency)
                     ) &&
                 (
                     Kind == other.Kind ||

                     Kind.Equals(other.Kind)
                 ) &&
                 (
                     TickSize == other.TickSize ||
                     TickSize != null &&
                     TickSize.Equals(other.TickSize)
                 ) &&
                 (
                     ContractSize == other.ContractSize ||
                     ContractSize != null &&
                     ContractSize.Equals(other.ContractSize)
                 ) &&
                 (
                     IsActive == other.IsActive ||
                     IsActive != null &&
                     IsActive.Equals(other.IsActive)
                 ) &&
                 (
                     OptionType == other.OptionType ||

                     OptionType.Equals(other.OptionType)
                 ) &&
                 (
                     MinTradeAmount == other.MinTradeAmount ||
                     MinTradeAmount != null &&
                     MinTradeAmount.Equals(other.MinTradeAmount)
                 ) &&
                 (
                     InstrumentName == other.InstrumentName ||
                     InstrumentName != null &&
                     InstrumentName.Equals(other.InstrumentName)
                 ) &&
                 (
                     SettlementPeriod == other.SettlementPeriod ||

                     SettlementPeriod.Equals(other.SettlementPeriod)
                 ) &&
                 (
                     Strike == other.Strike ||
                     Strike != null &&
                     Strike.Equals(other.Strike)
                 ) &&
                 (
                     BaseCurrency == other.BaseCurrency ||

                     BaseCurrency.Equals(other.BaseCurrency)
                 ) &&
                 (
                     CreationTimestamp == other.CreationTimestamp ||
                     CreationTimestamp != null &&
                     CreationTimestamp.Equals(other.CreationTimestamp)
                 ) &&
                 (
                     ExpirationTimestamp == other.ExpirationTimestamp ||
                     ExpirationTimestamp != null &&
                     ExpirationTimestamp.Equals(other.ExpirationTimestamp)
                 ));
        }