Пример #1
0
        public static HashSet <Expression> Nominate(Expression expression)
        {
            ExpressionNominator n = new ExpressionNominator();

            n.Visit(expression);
            return(n.candidates);
        }
Пример #2
0
        /// <summary>
        /// Performs evaluation & 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 PartialEval(Expression exp)
        {
            if (exp.NodeType == ExpressionType.Constant)
            {
                return(exp);
            }

            HashSet <Expression> candidates = ExpressionNominator.Nominate(exp);

            return(new ExpressionEvaluator(candidates).Visit(exp) !);
        }