/// <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 (Balance != null) { hashCode = hashCode * 59 + Balance.GetHashCode(); } if (UnrealizedPl != null) { hashCode = hashCode * 59 + UnrealizedPl.GetHashCode(); } if (Equity != null) { hashCode = hashCode * 59 + Equity.GetHashCode(); } if (AmData != null) { hashCode = hashCode * 59 + AmData.GetHashCode(); } return(hashCode); } }
public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks etc, of course :) if (Currency != null) { hash = hash * 59 + Currency.GetHashCode(); } hash = hash * 59 + Cash.GetHashCode(); hash = hash * 59 + Equity.GetHashCode(); hash = hash * 59 + Profit.GetHashCode(); hash = hash * 59 + DayProfit.GetHashCode(); return(hash); } }
public static object GetOrCreateAnalytic(this Equity equity, Type analyticType, params object[] parameters) { if (!typeof(IAnalyzable).IsAssignableFrom(analyticType)) { throw new ArgumentException($"{analyticType.Name} is not a valid object to create"); } string key = $"{equity.GetHashCode()}#{analyticType.Name}#{string.Join("|", parameters)}"; if (!_cache.TryGetValue(key, out object output)) { var paramsList = new List <object>(); paramsList.Add(equity); paramsList.AddRange(parameters); output = _cache.Set(key, Activator.CreateInstance(analyticType, paramsList.ToArray()), _policy); } return(output); }
/// <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); } }