Exemple #1
0
        public static Expression ReplaceExprList(Expression expr, IEnumerable <ExprRep> items)
        {
            Func <Expression, Expression> rep = ex =>
            {
                var        toRep  = ex;
                Expression result = ex;
                while (true)
                {
                    var find = items.Where(x => CompareExpr.ExprEquals(x.Find, toRep)).Select(x => x.Rep).FirstOrDefault();
                    if (find != null)
                    {
                        toRep  = find;
                        result = find;
                    }
                    else
                    {
                        break;
                    }
                }
                return(result);
            };

            return(ReplaceVisitor.Replace(expr, rep));
        }
Exemple #2
0
        public static Expression Replace(Expression Expression, Func <Expression, Expression> replace)
        {
            var V = new ReplaceVisitor(replace, x => x, x => false);

            return(V.Visit(Expression));
        }