예제 #1
0
 public void OnExpression()
 {
     if (expression_ == null)
     {
         expression_ = expressions_.Pop();
     }
 }
예제 #2
0
        public JmesPathFunctionArgument(JmesPathExpression expression)
        {
            System.Diagnostics.Debug.Assert(expression.IsExpressionType);

            token_      = null;
            expression_ = expression;
        }
예제 #3
0
 private void OnExpression()
 {
     if (expression_ == null)
     {
         expression_ = expressions_.Pop();
     }
 }
예제 #4
0
        public JmesPathFunctionArgument(JToken token)
        {
            System.Diagnostics.Debug.Assert(token != null);

            token_      = token;
            expression_ = null;
        }
        protected virtual void Assert(JmesPathExpression expression, string input, string expected)
        {
            var json   = JmesPath.ParseJson(input);
            var result = expression.Transform(json);
            var actual = result.AsJToken().AsString();

            Xunit.Assert.Equal(expected, actual);
        }
예제 #6
0
        public void OnExpressionType()
        {
            Prolog();

            var expression = expressions_.Pop();

            JmesPathExpression.MakeExpressionType(expression);
            expressions_.Push(expression);
        }
예제 #7
0
            public void Visit(JmesPathExpression expression)
            {
                var projection = expression as JmesPathSliceProjection;

                if (projection?.Step != null && projection.Step.Value == 0)
                {
                    throw new Exception("Error: invalid-value, a slice projection step cannot be 0.");
                }
            }
예제 #8
0
        bool Prolog()
        {
            if (expression_ != null)
            {
                expressions_.Push(expression_);
                expression_ = null;
                return(true);
            }

            return(false);
        }
        private void Assert(string[] expressions, string input, string expected)
        {
            JmesPathExpression expression = null;

            foreach (var identifier in expressions)
            {
                JmesPathExpression ident = new JmesPathIdentifier(identifier);
                expression = expression != null
                    ? new JmesPathSubExpression(expression, ident)
                    : ident
                ;
            }

            Assert(expression, input, expected);
        }
예제 #10
0
        protected JToken Evaluate(JmesPathExpression expression, JToken token)
        {
            var eval = expression.Transform(token).AsJToken();
            var type = eval.GetTokenType();

            if (type != "number" && type != "string")
            {
                throw new Exception($"Error: invalid-type, the expression argument of function {Name} should return a number or a string.");
            }

            if (type == "number")
            {
                return(eval);
            }

            double number;

            if (double.TryParse(eval.Value <string>(), out number))
            {
                return(new JValue(number));
            }

            throw new Exception("Error: invalid-type, when evaluating the expression argument of function {Name}, some items could not be cast to a number.");
        }
예제 #11
0
 internal Expression(JmesPathExpression expression)
 {
     expression_ = expression;
 }
예제 #12
0
 protected override JmesPathExpression CreateWith(JmesPathExpression left, JmesPathExpression right)
 => new JmesPathGreaterThanOrEqualOperator(left, right);
예제 #13
0
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathGreaterThanOrEqualOperator"/> class
 /// to perform a comparison between two specified expressions.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 public JmesPathGreaterThanOrEqualOperator(JmesPathExpression left, JmesPathExpression right)
     : base(left, right)
 {
 }
예제 #14
0
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathLessThanOperator"/> class
 /// to perform a comparison between two specified expressions.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 public JmesPathLessThanOperator(JmesPathExpression left, JmesPathExpression right)
     : base(left, right)
 {
 }
예제 #15
0
 internal Expression(JmesPathExpression expression)
 {
     InnerExpression = expression;
 }