public void A()
        {
            Expression <Func <int, bool> > expr = x => x + 5 < 10;
            var str = JsExpressionVisitor.ExpressionToString(expr);

            Assert.Equal("x => ((x + 5) < 10)", str);
        }
            internal static string SwitchCaseToString(SwitchCase node)
            {
                Debug.Assert(node != null);
                JsExpressionVisitor esb = new JsExpressionVisitor();

                esb.VisitSwitchCase(node);
                return(esb.ToString());
            }
            internal static string CatchBlockToString(CatchBlock node)
            {
                Debug.Assert(node != null);
                JsExpressionVisitor esb = new JsExpressionVisitor();

                esb.VisitCatchBlock(node);
                return(esb.ToString());
            }
            /// <summary>
            /// Output a given expression tree to a string.
            /// </summary>
            public static string ExpressionToString(Expression node)
            {
                Debug.Assert(node != null);
                JsExpressionVisitor esb = new JsExpressionVisitor();

                esb.Visit(node);
                return(esb.ToString());
            }
            /// <summary>
            /// Output a given ElementInit to a string.
            /// </summary>
            internal static string ElementInitBindingToString(ElementInit node)
            {
                Debug.Assert(node != null);
                JsExpressionVisitor esb = new JsExpressionVisitor();

                esb.VisitElementInit(node);
                return(esb.ToString());
            }
            /// <summary>
            /// Output a given member binding to a string.
            /// </summary>
            internal static string MemberBindingToString(MemberBinding node)
            {
                Debug.Assert(node != null);
                JsExpressionVisitor esb = new JsExpressionVisitor();

                esb.VisitMemberBinding(node);
                return(esb.ToString());
            }
示例#7
0
        public IActionResult Get()
        {
            Expression <Func <double, bool> > expression = x => x > 100;

            return(Ok(new
            {
                Predicate = JsExpressionVisitor.ExpressionToString(expression),
                ErrorMessage = "Price must > 100"
            }));
        }