Exemplo n.º 1
0
 /// <summary>
 /// Creates a new scope in which the <c>return</c> keyword will work.
 /// </summary>
 /// <returns>
 /// A <see cref="IDisposable" /> handle that will return to the previous scope when disposed.
 /// </returns>
 public IDisposable NewScope()
 {
     _current = _current == null ? new LabelScope() : new LabelScope(_current);
     return(new ScopeHandle(() => _current = _current?._parent));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new scope in which the <c>return</c> keyword will work while specifying an
 /// expected return type.
 /// </summary>
 /// <param name="returnType">The expected return type</param>
 /// <returns>
 /// A <see cref="IDisposable" /> handle that will return to the previous scope when disposed.
 /// </returns>
 public IDisposable NewScope(Type returnType)
 {
     _current            = _current == null ? new LabelScope() : new LabelScope(_current);
     _current.ReturnType = returnType;
     return(new ScopeHandle(() => _current = _current?._parent));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LabelScope" /> class.
 /// </summary>
 /// <param name="parent">The parent <see cref="LabelScope" />.</param>
 internal LabelScope(LabelScope parent)
 {
     _parent = parent;
 }