コード例 #1
0
        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;
            }
        }
コード例 #2
0
 public Scope(string name, ScopeJumpType jumpOutPolicy)
 {
     Name          = name;
     JumpOutPolicy = jumpOutPolicy;
 }