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

Label() public static method

Creates a LabelTarget representing a label with the given type and name.
public static Label ( Type type, string name ) : LabelTarget
type Type The type of value that is passed when jumping to the label.
name string The name of the label.
return LabelTarget
        public static LabelTarget Label(Type type, string name)
        {
            ContractUtils.RequiresNotNull(type, nameof(type));
            TypeUtils.ValidateType(type, nameof(type));
            return new LabelTarget(type, name);
        }
    }

Same methods

Expression::Label ( LabelTarget target ) : LabelExpression
Expression::Label ( LabelTarget target, Expression defaultValue ) : LabelExpression
Expression::Label ( ) : LabelTarget
Expression::Label ( Type type ) : LabelTarget
Expression::Label ( string name ) : LabelTarget

Usage Example

Exemplo n.º 1
0
        protected override object VisitDoWhile(DoWhile W)
        {
            string name = target.LabelName();

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

            target.PushScope();

            // Check the condition, exit if necessary.
            target.Add(LinqExpr.Label(begin));

            // Generate the body target.
            Visit(W.Body);

            // Loop.
            target.Add(LinqExpr.IfThen(target.Compile(W.Condition), LinqExpr.Goto(begin)));

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

            loops.Pop();
            target.PopScope();
            return(null);
        }
All Usage Examples Of System.Linq.Expressions.Expression::Label
Expression