コード例 #1
0
        protected override Expression OnBuild(ExpressionBuilderContext <ExpressionOptimizerState> context)
        {
            if (context.State.Hits <= 1)
            {
                return(context.Expression);
            }

            if (context.State.Index++ == 0)
            {
                ParameterExpression variable = context.State.Variable = Expression.Variable(context.Expression.Type);

                context.Variables.Add(variable);

                return(Expression.Assign(variable, context.Expression));
            }

            return(context.State.Variable);
        }
コード例 #2
0
        private Expression ScanHandler(Expression expression)
        {
            if (this.idMap.TryGetValue(expression, out object key))
            {
                ExpressionBuilderContext <TState> context = new ExpressionBuilderContext <TState>()
                {
                    Key        = key,
                    Batch      = this.exprMap[key],
                    Expression = expression,
                    State      = this.stateMap[key],
                    Variables  = new List <ParameterExpression>(),
                };

                this.OnScan(context);
            }


            return(expression);
        }
コード例 #3
0
        private Expression BuildHandler(Expression expression)
        {
            if (this.idMap.TryGetValue(expression, out object key))
            {
                ExpressionBuilderContext <TState> context = new ExpressionBuilderContext <TState>()
                {
                    Key        = key,
                    Batch      = this.exprMap[key],
                    Expression = expression,
                    State      = this.stateMap[key],
                    Variables  = new List <ParameterExpression>(),
                };

                Expression result = this.OnBuild(context);

                this.variables.AddRange(context.Variables);

                return(result);
            }

            return(expression);
        }
コード例 #4
0
 protected abstract Expression OnBuild(ExpressionBuilderContext <TState> context);
コード例 #5
0
 protected abstract void OnScan(ExpressionBuilderContext <TState> context);
コード例 #6
0
 protected override void OnScan(ExpressionBuilderContext <ExpressionOptimizerState> context)
 {
     context.State.Hits++;
 }