Apply() 공개 메소드

public Apply ( Expression expression ) : Expression
expression System.Linq.Expressions.Expression
리턴 System.Linq.Expressions.Expression
예제 #1
0
        public Expression AutoInline(InvocationExpression expression)
        {
            this.isLocked = true;
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            var lambda       = (LambdaExpression)expression.Expression;
            var childScope   = new ExpressionRewriter(this);
            var lambdaParams = lambda.Parameters;
            var invokeArgs   = expression.Arguments;

            if (lambdaParams.Count != invokeArgs.Count)
            {
                throw new InvalidOperationException("Lambda/invoke mismatch");
            }

            for (var i = 0; i < lambdaParams.Count; i++)
            {
                childScope.Substitute(lambdaParams[i], invokeArgs[i]);
            }

            return(childScope.Apply(lambda.Body));
        }
예제 #2
0
        public Expression AutoInline(InvocationExpression expression)
        {
            this.isLocked = true;
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            var lambda = (LambdaExpression)expression.Expression;
            var childScope = new ExpressionRewriter(this);
            var lambdaParams = lambda.Parameters;
            var invokeArgs = expression.Arguments;
            if (lambdaParams.Count != invokeArgs.Count)
            {
                throw new InvalidOperationException("Lambda/invoke mismatch");
            }

            for (var i = 0; i < lambdaParams.Count; i++)
            {
                childScope.Substitute(lambdaParams[i], invokeArgs[i]);
            }

            return childScope.Apply(lambda.Body);
        }