예제 #1
0
        public override object VisitValueWithVariable(GraphQLParser.ValueWithVariableContext context)
        {
            if (context.StringValue() != null)
            {
                var val = new StringValue(context.StringValue().GetText());
                NewNode(val, context);
                return(val);
            }

            if (context.IntValue() != null)
            {
                var value = context.IntValue().GetText();
                int intResult;
                if (int.TryParse(value, out intResult))
                {
                    var val = new IntValue(intResult);
                    NewNode(val, context);
                    return(val);
                }

                // If the value doesn't fit in an integer, revert to using long...
                long longResult;
                if (long.TryParse(value, out longResult))
                {
                    var val = new LongValue(longResult);
                    NewNode(val, context);
                    return(val);
                }
            }

            if (context.FloatValue() != null)
            {
                var val = new FloatValue(double.Parse(context.FloatValue().GetText()));
                NewNode(val, context);
                return(val);
            }

            if (context.BooleanValue() != null)
            {
                var val = new BooleanValue(bool.Parse(context.BooleanValue().GetText()));
                NewNode(val, context);
                return(val);
            }

            if (context.enumValue() != null)
            {
                var val = new EnumValue(context.enumValue().GetText());
                NewNode(val, context);
                return(val);
            }

            if (context.variable() != null)
            {
                return(Visit(context.variable()));
            }

            if (context.arrayValueWithVariable() != null)
            {
                return(Visit(context.arrayValueWithVariable()));
            }

            if (context.objectValueWithVariable() != null)
            {
                return(Visit(context.objectValueWithVariable()));
            }

            return(null);
        }
예제 #2
0
 protected bool Equals(BooleanValue other)
 {
     return(Value == other.Value);
 }