internal static Expression Rewrite(Expression @in, ParameterExpression what, Expression with) { if (what.Type != with.Type && !what.Type.IsAssignableFrom(with.Type)) with = Expression.Convert(with, what.Type); var visitor = new LambdaSubstituter(what, with); return visitor.Visit(@in); }
private static Expression <Func <T, bool> > Combine <T>(Expression <Func <T, bool> > head, IEnumerable <Expression <Func <T, bool> > > tail, Func <Expression, Expression, BinaryExpression> combiner) { var result = tail.Aggregate(head, (soFar, element) => { var lambda = LambdaSubstituter.ReplaceParameters(element, soFar.Parameters); return((Expression <Func <T, bool> >)Expression.Lambda(combiner(soFar.Body, lambda), soFar.Parameters)); }); return(result); }
internal static Expression Rewrite(Expression @in, ParameterExpression what, Expression with) { if (what.Type != with.Type && !what.Type.IsAssignableFrom(with.Type)) { with = Expression.Convert(with, what.Type); } var visitor = new LambdaSubstituter(what, with); return(visitor.Visit(@in)); }
protected override Expression VisitMethodCall(MethodCallExpression node) { if (AreTheSameMethod(node.Method, _what.Method)) { if (IsTheSameObject(node.Object, _what.Object)) { return(LambdaSubstituter.ReplaceParameters(_with, node.Arguments)); } } return(base.VisitMethodCall(node)); }
public static Expression Splice(this LambdaExpression e, params Expression[] newExpr) { return(LambdaSubstituter.ReplaceParameters(e, newExpr)); }
public static Expression Splice(this LambdaExpression e, IEnumerable <Expression> newExpr) { return(LambdaSubstituter.ReplaceParameters(e, newExpr)); }