/// <summary> /// Performs a deep-equality comparison. /// </summary> public bool Equals(LdValue o) { if (Type != o.Type) { return(false); } switch (Type) { case LdValueType.Null: return(true); case LdValueType.Bool: return(AsBool == o.AsBool); case LdValueType.Number: return(AsDouble == o.AsDouble); // don't worry about ints because you can't lose precision going from int to double case LdValueType.String: return(AsString.Equals(o.AsString)); case LdValueType.Array: return(AsList(Convert.Json).SequenceEqual(o.AsList(Convert.Json))); case LdValueType.Object: { var d0 = AsDictionary(Convert.Json); var d1 = o.AsDictionary(Convert.Json); return(d0.Count == d1.Count && d0.All(kv => d1.TryGetValue(kv.Key, out var v) && kv.Value.Equals(v))); } default: return(false); } }