예제 #1
0
        /// <summary>Re-initializes internal state to be ready for re-use.</summary>
        public void Reset()
        {
            // some declarations may be pending in nextScope
            nextScope.ClearMappings();
            // store active scopes for re-use
            NamespaceScope scope = topScope;

            if (scope != null)
            {
                // need to reset active scopes before storing them for re-use
                scope.ClearMappings();
                while (scope.parent != null)
                {
                    scope = scope.parent;
                    scope.ClearMappings();
                }
                // attach free scopes to end of active scopes
                scope.parent = nextScope;
                // move the whole stack from topScope to nextScope
                nextScope = topScope;
                topScope  = null;
            }
            // the 'xml' prefix is always declared
            nextScope.AddMapping("xml", Constants.XmlUri);
        }
예제 #2
0
 /// <summary>Deactivates namespace scope.</summary>
 /// <remarks>All namespace mappings that became active with this scope
 /// are going out of effect.</remarks>
 public void PopScope()
 {
     if (nextScope.emptyLevels > 0)
     {
         nextScope.emptyLevels--;
     }
     else if (topScope == null) // don't pop too many times
     {
         string msg = Resources.GetString(RsId.NoActiveNsScope);
         throw new InvalidOperationException(msg);
     }
     else
     {
         NamespaceScope oldNextScope = nextScope;
         // clear pending declarations
         oldNextScope.ClearMappings();
         nextScope        = topScope;
         topScope         = topScope.parent;
         nextScope.parent = oldNextScope;
         nextScope.ClearMappings();
     }
 }
예제 #3
0
 /// <summary>Deactivates namespace scope.</summary>
 /// <remarks>All namespace mappings that became active with this scope
 /// are going out of effect.</remarks>
 public void PopScope()
 {
     if (nextScope.emptyLevels > 0)
     nextScope.emptyLevels--;
       else if (topScope == null) {  // don't pop too many times
     string msg = Resources.GetString(RsId.NoActiveNsScope);
     throw new InvalidOperationException(msg);
       }
       else {
     NamespaceScope oldNextScope = nextScope;
     // clear pending declarations
     oldNextScope.ClearMappings();
     nextScope = topScope;
     topScope = topScope.parent;
     nextScope.parent = oldNextScope;
     nextScope.ClearMappings();
       }
 }