Beispiel #1
0
        public override bool Equals(IValue other)
        {
            if (other.ValueType != ValueType)
            {
                return(false);
            }

            switch (ValueType)
            {
            case ValueType.Boolean: {
                bool lhs, rhs;
                return(GetAsBoolean(out lhs) && other.GetAsBoolean(out rhs) && lhs == rhs);
            }

            case ValueType.Integer: {
                int lhs, rhs;
                return(GetAsInteger(out lhs) && other.GetAsInteger(out rhs) && lhs == rhs);
            }

            case ValueType.Real: {
                double lhs, rhs;
                return(GetAsReal(out lhs) && other.GetAsReal(out rhs) && lhs == rhs);
            }

            default:
                return(false);
            }
        }
Beispiel #2
0
        public void NumberFormat()
        {
            JSONReader reader = new JSONReader();
            IValue     root   = reader.JsonToValue("43", false, false);

            Assert.True(root.IsType(ValueType.Integer));
            Assert.AreEqual(43, root.GetAsInteger());
        }
    public override bool Equals(IValue other) {
      if (other.ValueType != ValueType)
        return false;

      switch (ValueType) {
        case ValueType.Boolean: {
            bool lhs, rhs;
            return GetAsBoolean(out lhs) && other.GetAsBoolean(out rhs) && lhs == rhs;
          }

        case ValueType.Integer: {
            int lhs, rhs;
            return GetAsInteger(out lhs) && other.GetAsInteger(out rhs) && lhs == rhs;
          }

        case ValueType.Real: {
            double lhs, rhs;
            return GetAsReal(out lhs) && other.GetAsReal(out rhs) && lhs == rhs;
          }

        default:
          return false;
      }
    }