/// <summary> /// Performs evaluation and replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <param name="fnPostEval">A function to apply to each newly formed <see cref="ConstantExpression"/>.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression Eval(Expression expression, Func <Expression, bool> fnCanBeEvaluated, Func <ConstantExpression, Expression> fnPostEval) { if (fnCanBeEvaluated == null) { fnCanBeEvaluated = PartialEvaluator.CanBeEvaluatedLocally; } return(SubtreeEvaluator.Eval(Nominator.Nominate(fnCanBeEvaluated, expression), fnPostEval, expression)); }
/// <summary> /// Performs evaluation and replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression Eval(Expression expression, Func <Expression, bool> fnCanBeEvaluated) { return(SubtreeEvaluator.Eval(Nominator.Nominate(fnCanBeEvaluated, expression), expression)); }