コード例 #1
0
        public Expression ReplaceIn(Expression target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            var visitor = new ExpressionReplacerVisitor(_replacements);

            return(visitor.Replace(target));
        }
コード例 #2
0
        public static Expression ReplaceParameters(this LambdaExpression lambda, params Expression[] replacer)
        {
            var original = lambda.Parameters;
            var len      = Math.Min(original.Count, replacer.Length);
            var result   = lambda.Body;

            for (int i = 0; i < len; i++)
            {
                result = new ExpressionReplacerVisitor(original[i], replacer[i]).Visit(result);
            }

            return(result);
        }
コード例 #3
0
 public Expression ReplaceIn(Expression target)
 {
     if (_target == null) { throw new ArgumentNullException("target"); }
     var visitor = new ExpressionReplacerVisitor(_replacements);
     return visitor.Replace(_target);
 }
コード例 #4
0
        public static Expression <Func <T, bool> > Combine <T, TProp>(this Expression <Func <T, TProp> > left, Expression <Func <TProp, bool> > right)
        {
            var body = new ExpressionReplacerVisitor(right.Parameters[0], left.Body).Visit(right.Body);

            return(Expression.Lambda <Func <T, bool> >(body, left.Parameters[0]));
        }