Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DomNameTable.cs
Go to the documentation of this file.
2
3namespace System.Xml;
4
5internal sealed class DomNameTable
6{
7 private XmlName[] _entries;
8
9 private int _count;
10
11 private int _mask;
12
13 private readonly XmlDocument _ownerDocument;
14
15 private readonly XmlNameTable _nameTable;
16
18 {
20 _nameTable = document.NameTable;
21 _entries = new XmlName[64];
22 _mask = 63;
23 }
24
25 public XmlName GetName(string prefix, string localName, string ns, IXmlSchemaInfo schemaInfo)
26 {
27 if (prefix == null)
28 {
29 prefix = string.Empty;
30 }
31 if (ns == null)
32 {
33 ns = string.Empty;
34 }
35 int hashCode = XmlName.GetHashCode(localName);
36 for (XmlName xmlName = _entries[hashCode & _mask]; xmlName != null; xmlName = xmlName.next)
37 {
38 if (xmlName.HashCode == hashCode && ((object)xmlName.LocalName == localName || xmlName.LocalName.Equals(localName)) && ((object)xmlName.Prefix == prefix || xmlName.Prefix.Equals(prefix)) && ((object)xmlName.NamespaceURI == ns || xmlName.NamespaceURI.Equals(ns)) && xmlName.Equals(schemaInfo))
39 {
40 return xmlName;
41 }
42 }
43 return null;
44 }
45
46 public XmlName AddName(string prefix, string localName, string ns, IXmlSchemaInfo schemaInfo)
47 {
48 if (prefix == null)
49 {
50 prefix = string.Empty;
51 }
52 if (ns == null)
53 {
54 ns = string.Empty;
55 }
56 int hashCode = XmlName.GetHashCode(localName);
57 for (XmlName xmlName = _entries[hashCode & _mask]; xmlName != null; xmlName = xmlName.next)
58 {
59 if (xmlName.HashCode == hashCode && ((object)xmlName.LocalName == localName || xmlName.LocalName.Equals(localName)) && ((object)xmlName.Prefix == prefix || xmlName.Prefix.Equals(prefix)) && ((object)xmlName.NamespaceURI == ns || xmlName.NamespaceURI.Equals(ns)) && xmlName.Equals(schemaInfo))
60 {
61 return xmlName;
62 }
63 }
65 localName = _nameTable.Add(localName);
66 ns = _nameTable.Add(ns);
67 int num = hashCode & _mask;
68 XmlName xmlName2 = XmlName.Create(prefix, localName, ns, hashCode, _ownerDocument, _entries[num], schemaInfo);
69 _entries[num] = xmlName2;
70 if (_count++ == _mask)
71 {
72 Grow();
73 }
74 return xmlName2;
75 }
76
77 private void Grow()
78 {
79 int num = _mask * 2 + 1;
81 XmlName[] array = new XmlName[num + 1];
82 for (int i = 0; i < entries.Length; i++)
83 {
85 while (xmlName != null)
86 {
87 int num2 = xmlName.HashCode & num;
88 XmlName next = xmlName.next;
91 xmlName = next;
92 }
93 }
95 _mask = num;
96 }
97}
DomNameTable(XmlDocument document)
readonly XmlNameTable _nameTable
XmlName GetName(string prefix, string localName, string ns, IXmlSchemaInfo schemaInfo)
readonly XmlDocument _ownerDocument
XmlName AddName(string prefix, string localName, string ns, IXmlSchemaInfo schemaInfo)
string Add(char[] array, int offset, int length)
static XmlName Create(string prefix, string localName, string ns, int hashCode, XmlDocument ownerDoc, XmlName next, IXmlSchemaInfo schemaInfo)
Definition XmlName.cs:78
static int GetHashCode(string name)
Definition XmlName.cs:103