/// <inheritdoc/> public override int GetHashCode() { switch (Type) { case LdValueType.Null: return(0); case LdValueType.Bool: return(AsBool.GetHashCode()); case LdValueType.Number: return(AsFloat.GetHashCode()); case LdValueType.String: return(AsString.GetHashCode()); case LdValueType.Array: { var h = new HashCodeBuilder(); foreach (var item in AsList(Convert.Json)) { h = h.With(item); } return(h.Value); } case LdValueType.Object: { var h = new HashCodeBuilder(); var d = AsDictionary(Convert.Json); var keys = d.Keys.ToArray(); Array.Sort(keys); // inefficient, but ensures determinacy foreach (var key in keys) { h = h.With(key).With(d[key]); } return(h.Value); } default: return(0); } }
/// <inheritdoc/> public override int GetHashCode() { var hashBuilder = new HashCodeBuilder() .With(Key) .With(Secondary) .With(IPAddress) .With(Country) .With(FirstName) .With(LastName) .With(Name) .With(Avatar) .With(Email) .With(Anonymous); foreach (var c in Custom) { hashBuilder = hashBuilder.With(c.Key).With(c.Value); } foreach (var p in PrivateAttributeNames) { hashBuilder = hashBuilder.With(p); } return(hashBuilder.Value); }