7 [global::__DynamicallyInvokable]
10 private struct NamespaceDeclaration
18 public int previousNsIndex;
20 public void Set(
string prefix,
string uri,
int scopeId,
int previousNsIndex)
24 this.scopeId = scopeId;
25 this.previousNsIndex = previousNsIndex;
31 private NamespaceDeclaration[] nsdecls;
41 private bool useHashtable;
47 private const int MinDeclsCountForHashtable = 16;
53 if (s_EmptyResolver ==
null)
57 return s_EmptyResolver;
63 [global::__DynamicallyInvokable]
66 [global::__DynamicallyInvokable]
75 [global::__DynamicallyInvokable]
78 [global::__DynamicallyInvokable]
98 [global::__DynamicallyInvokable]
101 this.nameTable = nameTable;
102 xml = nameTable.
Add(
"xml");
103 xmlNs = nameTable.
Add(
"xmlns");
104 nsdecls =
new NamespaceDeclaration[8];
105 string text = nameTable.
Add(
string.Empty);
106 nsdecls[0].Set(text, text, -1, -1);
107 nsdecls[1].Set(xmlNs, nameTable.
Add(
"http://www.w3.org/2000/xmlns/"), -1, -1);
108 nsdecls[2].Set(xml, nameTable.
Add(
"http://www.w3.org/XML/1998/namespace"), 0, -1);
114 [global::__DynamicallyInvokable]
123 [global::__DynamicallyInvokable]
131 while (nsdecls[num].scopeId == scopeId)
135 hashTable[nsdecls[num].prefix] = nsdecls[num].previousNsIndex;
150 [global::__DynamicallyInvokable]
161 prefix = nameTable.
Add(prefix);
162 uri = nameTable.
Add(uri);
163 if (Ref.Equal(xml, prefix) && !uri.Equals(
"http://www.w3.org/XML/1998/namespace"))
167 if (Ref.Equal(xmlNs, prefix))
171 int num = LookupNamespaceDecl(prefix);
172 int previousNsIndex = -1;
175 if (nsdecls[num].scopeId == scopeId)
177 nsdecls[num].uri = uri;
180 previousNsIndex = num;
182 if (lastDecl == nsdecls.Length - 1)
184 NamespaceDeclaration[] destinationArray =
new NamespaceDeclaration[nsdecls.Length * 2];
185 Array.
Copy(nsdecls, 0, destinationArray, 0, nsdecls.Length);
186 nsdecls = destinationArray;
188 nsdecls[++lastDecl].Set(prefix, uri, scopeId, previousNsIndex);
191 hashTable[prefix] = lastDecl;
193 else if (lastDecl >= 16)
196 for (
int i = 0; i <= lastDecl; i++)
198 hashTable[nsdecls[i].prefix] = i;
208 [global::__DynamicallyInvokable]
219 for (
int num = LookupNamespaceDecl(prefix); num != -1; num = nsdecls[num].previousNsIndex)
221 if (
string.Equals(nsdecls[num].uri, uri) && nsdecls[num].scopeId == scopeId)
223 nsdecls[num].uri =
null;
230 [global::__DynamicallyInvokable]
234 for (
int i = 0; i <= lastDecl; i++)
236 if (nsdecls[i].uri !=
null)
238 dictionary[nsdecls[i].prefix] = nsdecls[i].prefix;
241 return dictionary.Keys.GetEnumerator();
247 [global::__DynamicallyInvokable]
261 while (nsdecls[i].scopeId == scopeId)
269 for (; i <= lastDecl; i++)
271 string prefix = nsdecls[i].prefix;
272 string uri = nsdecls[i].uri;
277 dictionary[prefix] = uri;
281 dictionary.Remove(prefix);
291 [global::__DynamicallyInvokable]
294 int num = LookupNamespaceDecl(prefix);
297 return nsdecls[num].uri;
302 private int LookupNamespaceDecl(
string prefix)
308 while (value != -1 && nsdecls[value].uri ==
null)
310 value = nsdecls[value].previousNsIndex;
316 for (
int num = lastDecl; num >= 0; num--)
318 if ((
object)nsdecls[num].prefix == prefix && nsdecls[num].uri !=
null)
323 for (
int num2 = lastDecl; num2 >= 0; num2--)
325 if (
string.Equals(nsdecls[num2].prefix, prefix) && nsdecls[num2].uri !=
null)
336 [global::__DynamicallyInvokable]
339 for (
int num = lastDecl; num >= 0; num--)
341 if (
string.Equals(nsdecls[num].uri, uri))
343 string prefix = nsdecls[num].prefix;
357 [global::__DynamicallyInvokable]
361 while (nsdecls[num].scopeId == scopeId)
363 if (
string.Equals(nsdecls[num].prefix, prefix) && nsdecls[num].uri !=
null)
365 if (prefix.Length > 0 || nsdecls[num].uri.Length > 0)
376 internal bool GetNamespaceDeclaration(
int idx, out
string prefix, out
string uri)
378 idx = lastDecl - idx;
381 prefix = (uri =
null);
384 prefix = nsdecls[idx].prefix;
385 uri = nsdecls[idx].uri;
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
virtual bool PopScope()
Pops a namespace scope off the stack.
virtual void AddNamespace(string prefix, string uri)
Adds the given namespace to the collection.
XmlNamespaceScope
Defines the namespace scope.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
Implements a single-threaded T:System.Xml.XmlNameTable.
XmlNamespaceManager(XmlNameTable nameTable)
Initializes a new instance of the T:System.Xml.XmlNamespaceManager class with the specified T:System....
Resolves, adds, and removes namespaces to a collection and provides scope management for these namesp...
virtual string LookupPrefix(string uri)
Finds the prefix declared for the given namespace URI.
virtual XmlNameTable NameTable
Gets the T:System.Xml.XmlNameTable associated with this object.
virtual string DefaultNamespace
Gets the namespace URI for the default namespace.
virtual IEnumerator GetEnumerator()
Returns an enumerator to use to iterate through the namespaces in the T:System.Xml....
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Table of atomized string objects.
virtual void RemoveNamespace(string prefix, string uri)
Removes the given namespace for the given prefix.
The exception that is thrown when one of the arguments provided to a method is not valid.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
virtual void PushScope()
Pushes a namespace scope onto the stack.
abstract string Add(char[] array, int offset, int length)
When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable.
virtual IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
Gets a collection of namespace names keyed by prefix which can be used to enumerate the namespaces cu...
virtual bool HasNamespace(string prefix)
Gets a value indicating whether the supplied prefix has a namespace defined for the current pushed sc...
Provides read-only access to a set of prefix and namespace mappings.
virtual string LookupNamespace(string prefix)
Gets the namespace URI for the specified prefix.
bool TryGetValue(TKey key, out TValue value)
Gets the value associated with the specified key.
Supports a simple iteration over a non-generic collection.