/// <summary> /// Returns true if CurrencyPortfolio instances are equal /// </summary> /// <param name="other">Instance of CurrencyPortfolio to be compared</param> /// <returns>Boolean</returns> public bool Equals(CurrencyPortfolio other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( MaintenanceMargin == other.MaintenanceMargin || MaintenanceMargin != null && MaintenanceMargin.Equals(other.MaintenanceMargin) ) && ( AvailableWithdrawalFunds == other.AvailableWithdrawalFunds || AvailableWithdrawalFunds != null && AvailableWithdrawalFunds.Equals(other.AvailableWithdrawalFunds) ) && ( InitialMargin == other.InitialMargin || InitialMargin != null && InitialMargin.Equals(other.InitialMargin) ) && ( AvailableFunds == other.AvailableFunds || AvailableFunds != null && AvailableFunds.Equals(other.AvailableFunds) ) && ( Currency == other.Currency || Currency.Equals(other.Currency) ) && ( MarginBalance == other.MarginBalance || MarginBalance != null && MarginBalance.Equals(other.MarginBalance) ) && ( Equity == other.Equity || Equity != null && Equity.Equals(other.Equity) ) && ( Balance == other.Balance || Balance != null && Balance.Equals(other.Balance) )); }
/// <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 (MaintenanceMargin != null) { hashCode = hashCode * 59 + MaintenanceMargin.GetHashCode(); } if (AvailableWithdrawalFunds != null) { hashCode = hashCode * 59 + AvailableWithdrawalFunds.GetHashCode(); } if (InitialMargin != null) { hashCode = hashCode * 59 + InitialMargin.GetHashCode(); } if (AvailableFunds != null) { hashCode = hashCode * 59 + AvailableFunds.GetHashCode(); } hashCode = hashCode * 59 + Currency.GetHashCode(); if (MarginBalance != null) { hashCode = hashCode * 59 + MarginBalance.GetHashCode(); } if (Equity != null) { hashCode = hashCode * 59 + Equity.GetHashCode(); } if (Balance != null) { hashCode = hashCode * 59 + Balance.GetHashCode(); } return(hashCode); } }