Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlAttributeCache.cs
Go to the documentation of this file.
2
4
6{
7 private struct AttrNameVal
8 {
9 private string _localName;
10
11 private string _prefix;
12
13 private string _namespaceName;
14
15 private string _text;
16
18
19 private int _hashCode;
20
21 private int _nextNameIndex;
22
23 public string LocalName => _localName;
24
25 public string Prefix => _prefix;
26
27 public string Namespace => _namespaceName;
28
29 public string Text => _text;
30
32
33 public int NextNameIndex
34 {
35 get
36 {
37 return _nextNameIndex;
38 }
39 set
40 {
42 }
43 }
44
45 public void Init(string prefix, string localName, string ns, int hashCode)
46 {
47 _localName = localName;
49 _namespaceName = ns;
50 _hashCode = hashCode;
52 }
53
54 public void Init(string text)
55 {
56 _text = text;
57 _value = null;
58 }
59
61 {
62 _text = null;
63 _value = value;
64 }
65
66 public bool IsDuplicate(string localName, string ns, int hashCode)
67 {
68 if (_localName != null && _hashCode == hashCode && _localName.Equals(localName) && _namespaceName.Equals(ns))
69 {
70 _localName = null;
71 return true;
72 }
73 return false;
74 }
75 }
76
78
79 private OnRemoveWriter _onRemove;
80
82
83 private int _numEntries;
84
85 private int _idxLastName;
86
87 private int _hashCodeUnion;
88
89 public int Count => _numEntries;
90
91 public OnRemoveWriter OnRemoveWriterEvent
92 {
93 set
94 {
96 }
97 }
98
100 {
102 _numEntries = 0;
103 _idxLastName = 0;
104 _hashCodeUnion = 0;
105 }
106
115
116 public override void WriteStartAttribute(string prefix, string localName, string ns)
117 {
118 int num = 0;
119 int num2 = 1 << (localName[0] & 0x1F);
120 if ((_hashCodeUnion & num2) != 0)
121 {
122 while (!_arrAttrs[num].IsDuplicate(localName, ns, num2))
123 {
124 num = _arrAttrs[num].NextNameIndex;
125 if (num == 0)
126 {
127 break;
128 }
129 }
130 }
131 else
132 {
134 }
136 if (_numEntries != 0)
137 {
139 }
141 _arrAttrs[_idxLastName].Init(prefix, localName, ns, num2);
142 }
143
144 public override void WriteEndAttribute()
145 {
146 }
147
148 internal override void WriteNamespaceDeclaration(string prefix, string ns)
149 {
152 }
153
154 public override void WriteString(string text)
155 {
158 }
159
160 public override void WriteValue(object value)
161 {
164 }
165
166 public override void WriteValue(string value)
167 {
169 }
170
171 internal override void StartElementContent()
172 {
175 }
176
177 public override void WriteStartElement(string prefix, string localName, string ns)
178 {
179 }
180
181 internal override void WriteEndElement(string prefix, string localName, string ns)
182 {
183 }
184
185 public override void WriteComment(string text)
186 {
187 }
188
189 public override void WriteProcessingInstruction(string name, string text)
190 {
191 }
192
193 public override void WriteEntityRef(string name)
194 {
195 }
196
197 public override void Close()
198 {
199 _wrapped.Close();
200 }
201
202 public override void Flush()
203 {
204 _wrapped.Flush();
205 }
206
207 private void FlushAttributes()
208 {
209 int num = 0;
210 while (num != _numEntries)
211 {
212 int num2 = _arrAttrs[num].NextNameIndex;
213 if (num2 == 0)
214 {
216 }
217 string localName = _arrAttrs[num].LocalName;
218 if (localName != null)
219 {
220 string prefix = _arrAttrs[num].Prefix;
221 string @namespace = _arrAttrs[num].Namespace;
222 _wrapped.WriteStartAttribute(prefix, localName, @namespace);
223 while (++num != num2)
224 {
225 string text = _arrAttrs[num].Text;
226 if (text != null)
227 {
229 }
230 else
231 {
232 _wrapped.WriteValue(_arrAttrs[num].Value);
233 }
234 }
236 }
237 else
238 {
239 num = num2;
240 }
241 }
242 if (_onRemove != null)
243 {
245 }
246 }
247
248 private void EnsureAttributeCache()
249 {
250 if (_arrAttrs == null)
251 {
252 _arrAttrs = new AttrNameVal[32];
253 }
254 else if (_numEntries >= _arrAttrs.Length)
255 {
259 }
260 }
261}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
virtual void Close(WriteState currentState)
override void WriteValue(object value)
void WriteNamespaceDeclaration(string prefix, string ns)
void WriteString(string? text)
void WriteStartAttribute(string localName, string? ns)
Definition XmlWriter.cs:67
override void WriteNamespaceDeclaration(string prefix, string ns)
override void WriteProcessingInstruction(string name, string text)
override void WriteStartElement(string prefix, string localName, string ns)
override void WriteStartAttribute(string prefix, string localName, string ns)
override void WriteEndElement(string prefix, string localName, string ns)
void Init(string prefix, string localName, string ns, int hashCode)
bool IsDuplicate(string localName, string ns, int hashCode)