public void ValidateJumpOutTo(Scope target, ScopeJumpType jumpType, string exceptionMessageFormat) { var scope = this; while (scope != target) { if (scope == null) { throw new ScopeChangeException("The target scope has to be one of outer scopes of current scope."); } if ((scope.JumpOutPolicy & jumpType) != jumpType) { throw new ScopeChangeException(string.Format(exceptionMessageFormat, scope)); } scope = scope.Outer; } }
public Scope(string name, ScopeJumpType jumpOutPolicy) { Name = name; JumpOutPolicy = jumpOutPolicy; }