Esempio n. 1
0
        public ParameterExpression BuildVariable(Expression expr, string name = null)
        {
            if (name == null)
            {
                name = expr.Type.Name + Interlocked.Increment(ref VarIndex);
            }

            var variable = Expression.Variable(
                expr.Type,
                name.IndexOf('<') >= 0 ? null : name);

            BlockVariables.Add(variable);
            BlockExpressions.Add(Expression.Assign(variable, expr));

            return(variable);
        }
        public Expression BuildBlock(Expression expression)
        {
#if FW4 || SILVERLIGHT
            if (IsBlockDisable || BlockExpressions.Count == 0)
            {
                return(expression);
            }

            BlockExpressions.Add(expression);

            expression = Expression.Block(BlockVariables, BlockExpressions);

            BlockVariables.Clear();
            BlockExpressions.Clear();
#endif

            return(expression);
        }
Esempio n. 3
0
        public Expression BuildBlock(Expression expression)
        {
            if (IsBlockDisable || BlockExpressions.Count == 0)
            {
                return(expression);
            }

            BlockExpressions.Add(expression);

            expression = Expression.Block(BlockVariables, BlockExpressions);

            while (BlockVariables.Count > 1)
            {
                BlockVariables.RemoveAt(BlockVariables.Count - 1);
            }
            while (BlockExpressions.Count > 1)
            {
                BlockExpressions.RemoveAt(BlockExpressions.Count - 1);
            }

            return(expression);
        }