public bool Equals(CosmosNumber number1, CosmosNumber number2) { double double1; if (number1.IsFloatingPoint) { double1 = number1.AsFloatingPoint().Value; } else { double1 = number1.AsInteger().Value; } double double2; if (number2.IsFloatingPoint) { double2 = number2.AsFloatingPoint().Value; } else { double2 = number2.AsInteger().Value; } return(double1 == double2); }
public bool Equals(CosmosNumber number1, CosmosNumber number2) { if (number1.NumberType != number2.NumberType) { return(false); } else { return(number1.Value == number2.Value); } }
public static CosmosElement Dispatch( IJsonNavigator jsonNavigator, IJsonNavigatorNode jsonNavigatorNode) { JsonNodeType jsonNodeType = jsonNavigator.GetNodeType(jsonNavigatorNode); CosmosElement item; switch (jsonNodeType) { case JsonNodeType.Null: item = CosmosNull.Create(); break; case JsonNodeType.False: item = CosmosBoolean.Create(false); break; case JsonNodeType.True: item = CosmosBoolean.Create(true); break; case JsonNodeType.Number: item = CosmosNumber.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.FieldName: case JsonNodeType.String: item = CosmosString.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Array: item = CosmosArray.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Object: item = CosmosObject.Create(jsonNavigator, jsonNavigatorNode); break; default: throw new ArgumentException($"Unknown {nameof(JsonNodeType)}: {jsonNodeType}"); } return(item); }
public bool Equals(CosmosNumber number1, CosmosNumber number2) { if (number1.NumberType != number2.NumberType) { return(false); } else if (number1.NumberType == CosmosNumberType.Number64) { double double1; if (number1.IsFloatingPoint) { double1 = number1.AsFloatingPoint().Value; } else { double1 = number1.AsInteger().Value; } double double2; if (number2.IsFloatingPoint) { double2 = number2.AsFloatingPoint().Value; } else { double2 = number2.AsInteger().Value; } return(double1 == double2); } else if (number1.IsFloatingPoint) { return(number1.AsFloatingPoint() == number2.AsFloatingPoint()); } else { return(number1.AsInteger() == number2.AsInteger()); } }
public static bool TryParse(string json, out CosmosNumber cosmosNumber) { return(CosmosElement.TryParse <CosmosNumber>(json, out cosmosNumber)); }
public static bool TryCreateFromBuffer(ReadOnlyMemory <byte> buffer, out CosmosNumber cosmosNumber) { return(CosmosElement.TryCreateFromBuffer <CosmosNumber>(buffer, out cosmosNumber)); }