/// <summary>
        /// Takes an expression tree and finds and evaluates all its evaluatable subtrees.
        /// </summary>
        public static Expression EvaluateIndependentSubtrees(
            Expression expressionTree,
            PreTransformationParameters preTransformationParameters)
        {
            var partialEvaluationInfo = EvaluatableTreeFindingExpressionVisitor.Analyze(
                expressionTree,
                preTransformationParameters.EvaluatableExpressionFilter);
            var visitor = new NhPartialEvaluatingExpressionVisitor(partialEvaluationInfo, preTransformationParameters);

            return(visitor.Visit(expressionTree));
        }
Example #2
0
        public static PartialEvaluationInfo Analyze(Expression expressionTree, IEvaluatableExpressionFilter evaluatableExpressionFilter)
        {
            if (expressionTree == null)
            {
                throw new ArgumentNullException(nameof(expressionTree));
            }
            if (evaluatableExpressionFilter == null)
            {
                throw new ArgumentNullException(nameof(evaluatableExpressionFilter));
            }
            var visitor = new EvaluatableTreeFindingExpressionVisitor(evaluatableExpressionFilter);

            visitor.Visit(expressionTree);
            return(visitor.PartialEvaluationInfo);
        }