Exemple #1
0
        private ParameterExpression addPluginTypeVariable(BlockPlan plan)
        {
            var pluginTypeVariable = plan.FindVariableOfType(_pluginType);

            if (pluginTypeVariable == null)
            {
                pluginTypeVariable = Expression.Variable(_pluginType, "returnValue");
                plan.AddVariable(pluginTypeVariable);

                plan.Add(Expression.Assign(pluginTypeVariable, Expression.Convert(_variable, _pluginType)));
            }
            return(pluginTypeVariable);
        }
        public Expression ToExpression(ParameterExpression session, ParameterExpression context)
        {
            // Seed the plan with the inner value
            var inner = _inner.ToExpression(session, context);
            var plan  = new BlockPlan();

            plan.AddVariable(_variable);
            var assignment = Expression.Assign(_variable, inner);

            plan.Add(assignment);

            addActivations(plan);

            var pluginTypeVariable = addPluginTypeVariable(plan);

            addDecorators(context, pluginTypeVariable, plan);

            createTheReturnValue(pluginTypeVariable, plan);

            return(plan.ToExpression());
        }