예제 #1
0
        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);
        }
예제 #2
0
 public bool Equals(CosmosNumber number1, CosmosNumber number2)
 {
     if (number1.NumberType != number2.NumberType)
     {
         return(false);
     }
     else
     {
         return(number1.Value == number2.Value);
     }
 }
예제 #3
0
        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);
        }
예제 #4
0
        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());
            }
        }
예제 #5
0
 public static bool TryParse(string json, out CosmosNumber cosmosNumber)
 {
     return(CosmosElement.TryParse <CosmosNumber>(json, out cosmosNumber));
 }
예제 #6
0
 public static bool TryCreateFromBuffer(ReadOnlyMemory <byte> buffer, out CosmosNumber cosmosNumber)
 {
     return(CosmosElement.TryCreateFromBuffer <CosmosNumber>(buffer, out cosmosNumber));
 }