示例#1
0
 private void AddNamespace(string prefix, string uri, bool atomizedNames)
 {
     if (prefix == null)
     {
         throw new ArgumentNullException("prefix", "Value cannot be null.");
     }
     if (uri == null)
     {
         throw new ArgumentNullException("uri", "Value cannot be null.");
     }
     if (!atomizedNames)
     {
         prefix = this.nameTable.Add(prefix);
         uri    = this.nameTable.Add(uri);
     }
     if (prefix == "xml" && uri == "http://www.w3.org/XML/1998/namespace")
     {
         return;
     }
     XmlNamespaceManager.IsValidDeclaration(prefix, uri, true);
     if (prefix.Length == 0)
     {
         this.defaultNamespace = uri;
     }
     for (int i = this.declPos; i > this.declPos - this.count; i--)
     {
         if (object.ReferenceEquals(this.decls[i].Prefix, prefix))
         {
             this.decls[i].Uri = uri;
             return;
         }
     }
     this.declPos++;
     this.count++;
     if (this.declPos == this.decls.Length)
     {
         this.GrowDecls();
     }
     this.decls[this.declPos].Prefix = prefix;
     this.decls[this.declPos].Uri    = uri;
 }