Inheritance: System.Linq.Expressions.ExpressionVisitor
Example #1
0
        public static Expression Replace(InvocationExpression invocation)
        {
            LambdaExpression lambda = (LambdaExpression)invocation.Expression;
            var replacer            = new ExpressionReplacer(0.To(lambda.Parameters.Count).ToDictionaryEx(i => lambda.Parameters[i], i => invocation.Arguments[i]));

            return(replacer.Visit(lambda.Body));
        }
        public static Expression Replace(Expression expression, Dictionary <ParameterExpression, Expression> replacements)
        {
            var replacer = new ExpressionReplacer()
            {
                replacements = replacements
            };

            return(replacer.Visit(expression));
        }
        public static Expression Replace(Expression expression, Dictionary<ParameterExpression, Expression> replacements)
        {
            var replacer = new ExpressionReplacer()
            {
                replacements = replacements
            };

            return replacer.Visit(expression);
        }
        public static Expression Replace(InvocationExpression invocation)
        {
            LambdaExpression lambda = invocation.Expression as LambdaExpression;
            var replacer = new ExpressionReplacer()
            {
                replacements = 0.To(lambda.Parameters.Count).ToDictionaryEx(i => lambda.Parameters[i], i => invocation.Arguments[i])
            };

            return replacer.Visit(lambda.Body); 
        }
 protected override Expression VisitInvocation(InvocationExpression iv)
 {
     if (iv.Expression is LambdaExpression)
     {
         return(Visit(ExpressionReplacer.Replace(iv)));
     }
     else
     {
         return(base.VisitInvocation(iv)); //Just calling a delegate in the projector
     }
 }