コード例 #1
0
            internal static HashSet <Expression> Nominate(Func <Expression, bool> fnCanBeEvaluated, Expression expression)
            {
                var nominator = new Nominator(fnCanBeEvaluated);

                nominator.Visit(expression);
                return(nominator.candidates);
            }
コード例 #2
0
 /// <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));
 }
コード例 #3
0
            public static HashSet <Expression> Nominate(Func <Expression, bool> fnCanBeEvaluated, Expression expression)
            {
                var nominator = new Nominator(fnCanBeEvaluated);

                if (nominator != null)
                {
                    nominator.Visit(expression);
                }

                return(nominator.candidates);
            }
コード例 #4
0
 /// <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));
 }