Exemplo n.º 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));
    }
Exemplo n.º 2
0
            public static Expression Replace(Expression expression, ParameterExpression searchExp, ParameterExpression replaceExp)
            {
                var replacer = new ExpressionReplacer {
                    searchExp = searchExp, replaceExp = replaceExp
                };

                return(replacer.Visit(expression));
            }
Exemplo n.º 3
0
        protected static Expression ModifyExpressionAndReturnResult(Expression expression, IQueryable queryableEntities, MethodCallExpression expressionToReplace, MethodInfo replacingMethod)
        {
            var replacingExpression = GetReplacingExpression(expressionToReplace, queryableEntities, replacingMethod);

            var treeModifier = new ExpressionReplacer(expressionToReplace, replacingExpression);

            return(treeModifier.Visit(expression));
        }
Exemplo n.º 4
0
        private Expression ReplaceExpression(Expression body, Expression source, Expression dest)
        {
            var replacer = new ExpressionReplacer(source, dest);

            return(replacer.Visit(body));
        }
Exemplo n.º 5
0
            private static TExpression ReplaceParameter <TExpression>(TExpression expr, ParameterExpression toReplace, ParameterExpression replacement) where TExpression : Expression
            {
                var replacer = new ExpressionReplacer(e => e == toReplace ? replacement : e);

                return((TExpression)replacer.Visit(expr));
            }
Exemplo n.º 6
0
    public static Expression Replace(Expression expression, Dictionary <ParameterExpression, Expression> replacements)
    {
        var replacer = new ExpressionReplacer(replacements);

        return(replacer.Visit(expression));
    }
Exemplo n.º 7
0
    public static Expression Replace(Expression expression, ICollection <ParameterExpression> pars)
    {
        ExpressionReplacer replacer = new ExpressionReplacer(pars);

        return(replacer.Visit(expression));
    }
Exemplo n.º 8
0
        internal static T ReplaceParameter <T>(T expr, ParameterExpression toReplace, ParameterExpression replacement) where T : System.Linq.Expressions.Expression
        {
            var replacer = new ExpressionReplacer(e => e == toReplace ? replacement : e);

            return((T)replacer.Visit(expr));
        }