Beispiel #1
0
        public object Invoke(Expression.Expression expression)
        {
            var csExpression = Evaluate(expression);

            return(System.Linq.Expressions.Expression.Lambda(
                       csExpression,
                       Parameters.Select(o => o.Value)
                       )
                   .Compile()
                   .DynamicInvoke(Context.Select(o => o.Value).ToArray()));
        }
Beispiel #2
0
        public System.Linq.Expressions.Expression Evaluate(Expression.Expression expression)
        {
            switch (expression)
            {
            case TernaryExpression ternaryExpression:
                return(EvaluateTernaryExpression(ternaryExpression));

                break;

            case BinaryExpression binaryExpression:
                return(EvaluateBinaryExpression(binaryExpression));

                break;

            case UnaryExpression unaryExpression:
                return(EvaluateUnaryExpression(unaryExpression));

                break;

            case GroupExpression groupExpression:
                return(EvaluateGroupExpression(groupExpression));

                break;

            case FunctionCallExpression functionCallExpression:
                return(EvaluateFunctionCallExpression(functionCallExpression));

                break;

            case ConstantExpression constantExpression:
                return(EvaluateConstantExpression(constantExpression));

                break;

            case VariableExpression variableExpression:
                return(EvaluateVariableExpression(variableExpression));

                break;

            case MemberAccessExpression memberAccessExpression:
                return(EvaluateMemberAccessExpression(memberAccessExpression));

                break;

            case ArrayAccessExpression arrayAccessExpression:
                return(EvaluateArrayAccessExpression(arrayAccessExpression));

                break;
            }

            return(null);
        }
        protected void Visit(Expression.Expression expression)
        {
            switch (expression)
            {
            case TernaryExpression ternaryExpression:
                VisitTernaryExpression(ternaryExpression);
                break;

            case BinaryExpression binaryExpression:
                VisitBinaryExpression(binaryExpression);
                break;

            case UnaryExpression unaryExpression:
                VisitUnaryExpression(unaryExpression);
                break;

            case GroupExpression groupExpression:
                VisitGroupExpression(groupExpression);
                break;

            case FunctionCallExpression functionCallExpression:
                VisitFunctionCallExpression(functionCallExpression);
                break;

            case ConstantExpression constantExpression:
                VisitConstantExpression(constantExpression);
                break;

            case VariableExpression variableExpression:
                VisitVariableExpression(variableExpression);
                break;

            case MemberAccessExpression memberAccessExpression:
                VisitMemberAccessExpression(memberAccessExpression);
                break;

            case ArrayAccessExpression arrayAccessExpression:
                VisitArrayAccessExpression(arrayAccessExpression);
                break;
            }
        }