System.Linq.Expressions.Expression.IfThen C# (CSharp) Method

IfThen() public static method

Creates a ConditionalExpression.
public static IfThen ( Expression test, Expression ifTrue ) : ConditionalExpression
test Expression An to set the property equal to.
ifTrue Expression An to set the property equal to.
return ConditionalExpression
        public static ConditionalExpression IfThen(Expression test, Expression ifTrue)
        {
            return Condition(test, ifTrue, Expression.Empty(), typeof(void));
        }

Usage Example

Ejemplo n.º 1
0
        protected override object VisitFor(For F)
        {
            target.PushScope();

            // Generate the loop header code.
            Visit(F.Init);

            string name = target.LabelName();

            LinqExprs.LabelTarget begin = LinqExpr.Label("for_" + name + "_begin");
            LinqExprs.LabelTarget end   = LinqExpr.Label("for_" + name + "_end");
            loops.Push(new Loop(LinqExpr.Goto(end), LinqExpr.Goto(begin)));

            // Check the condition, exit if necessary.
            target.Add(LinqExpr.Label(begin));
            target.Add(LinqExpr.IfThen(LinqExpr.Not(target.Compile(F.Condition)), LinqExpr.Goto(end)));

            // Generate the body code.
            Visit(F.Body);

            // Generate the step code.
            Visit(F.Step);
            target.Add(LinqExpr.Goto(begin));

            // Exit point.
            target.Add(LinqExpr.Label(end));

            loops.Pop();
            target.PopScope();

            return(null);
        }
All Usage Examples Of System.Linq.Expressions.Expression::IfThen
Expression