示例#1
0
        protected override LinqExpression BuildLinqExpression()
        {
            var leftOperandExpression  = LeftNode.GetEvaluationLinqExpression();
            var rightOperandExpression = RightNode.GetEvaluationLinqExpression();

            var variableLeft            = LinqExpression.Variable(typeof(object));
            var variableEvaluatedResult = LinqExpression.Variable(typeof(object));

            return(LinqExpression.Block(
                       typeof(object),
                       new[] { variableLeft, variableEvaluatedResult },
                       LinqExpressionHelper.ExpressionCallThrowIfCancellationRequested,
                       LinqExpression.Assign(variableLeft, leftOperandExpression),
                       LinqExpression.IfThen(
                           LinqExpression.Not(
                               LinqExpression.Call(
                                   LinqExpression.Constant(Operator),
                                   LinqExpressionHelper.MethodInfoBinaryOperatorEvaluateLhs,
                                   LinqExpressionHelper.ExpressionParameterContext,
                                   variableLeft,
                                   variableEvaluatedResult)),
                           LinqExpression.Assign(
                               variableEvaluatedResult,
                               LinqExpression.Call(
                                   LinqExpression.Constant(Operator),
                                   LinqExpressionHelper.MethodInfoBinaryOperatorEvaluate,
                                   LinqExpressionHelper.ExpressionParameterContext,
                                   variableLeft,
                                   rightOperandExpression))),
                       variableEvaluatedResult));
        }
        protected override LinqExpression BuildLinqExpression()
        {
            var operandExpression = RightNode.GetEvaluationLinqExpression();

            return(LinqExpression.Block(
                       typeof(object),
                       LinqExpressionHelper.ExpressionCallThrowIfCancellationRequested,
                       LinqExpression.Call(LinqExpression.Constant(Operator), LinqExpressionHelper.MethodInfoUnaryOperatorEvaluate, LinqExpressionHelper.ExpressionParameterContext, operandExpression)));
        }