Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlNodeReader.cs
Go to the documentation of this file.
3
4namespace System.Xml;
5
7{
9
11
12 private int _curDepth;
13
15
16 private bool _fEOF;
17
18 private bool _bResolveEntity;
19
20 private bool _bStartFromDocument;
21
22 private bool _bInReadBinary;
23
25
26 public override XmlNodeType NodeType
27 {
28 get
29 {
30 if (!IsInReadingStates())
31 {
32 return XmlNodeType.None;
33 }
34 return _nodeType;
35 }
36 }
37
38 public override string Name
39 {
40 get
41 {
42 if (!IsInReadingStates())
43 {
44 return string.Empty;
45 }
46 return _readerNav.Name;
47 }
48 }
49
50 public override string LocalName
51 {
52 get
53 {
54 if (!IsInReadingStates())
55 {
56 return string.Empty;
57 }
58 return _readerNav.LocalName;
59 }
60 }
61
62 public override string NamespaceURI
63 {
64 get
65 {
66 if (!IsInReadingStates())
67 {
68 return string.Empty;
69 }
71 }
72 }
73
74 public override string Prefix
75 {
76 get
77 {
78 if (!IsInReadingStates())
79 {
80 return string.Empty;
81 }
82 return _readerNav.Prefix;
83 }
84 }
85
86 public override bool HasValue
87 {
88 get
89 {
90 if (!IsInReadingStates())
91 {
92 return false;
93 }
94 return _readerNav.HasValue;
95 }
96 }
97
98 public override string Value
99 {
100 get
101 {
102 if (!IsInReadingStates())
103 {
104 return string.Empty;
105 }
106 return _readerNav.Value;
107 }
108 }
109
110 public override int Depth => _curDepth;
111
112 public override string BaseURI => _readerNav.BaseURI;
113
114 public override bool CanResolveEntity => true;
115
116 public override bool IsEmptyElement
117 {
118 get
119 {
120 if (!IsInReadingStates())
121 {
122 return false;
123 }
125 }
126 }
127
128 public override bool IsDefault
129 {
130 get
131 {
132 if (!IsInReadingStates())
133 {
134 return false;
135 }
136 return _readerNav.IsDefault;
137 }
138 }
139
140 public override XmlSpace XmlSpace
141 {
142 get
143 {
144 if (!IsInReadingStates())
145 {
146 return XmlSpace.None;
147 }
148 return _readerNav.XmlSpace;
149 }
150 }
151
152 public override string XmlLang
153 {
154 get
155 {
156 if (!IsInReadingStates())
157 {
158 return string.Empty;
159 }
160 return _readerNav.XmlLang;
161 }
162 }
163
164 public override IXmlSchemaInfo? SchemaInfo
165 {
166 get
167 {
168 if (!IsInReadingStates())
169 {
170 return null;
171 }
172 return _readerNav.SchemaInfo;
173 }
174 }
175
176 public override int AttributeCount
177 {
178 get
179 {
180 if (!IsInReadingStates() || _nodeType == XmlNodeType.EndElement)
181 {
182 return 0;
183 }
185 }
186 }
187
188 public override bool EOF
189 {
190 get
191 {
192 if (_readState != ReadState.Closed)
193 {
194 return _fEOF;
195 }
196 return false;
197 }
198 }
199
200 public override ReadState ReadState => _readState;
201
202 public override bool HasAttributes => AttributeCount > 0;
203
205
206 public override bool CanReadBinaryContent => true;
207
209
211 {
212 if (node == null)
213 {
214 throw new ArgumentNullException("node");
215 }
217 _curDepth = 0;
218 _readState = ReadState.Initial;
219 _fEOF = false;
220 _nodeType = XmlNodeType.None;
221 _bResolveEntity = false;
222 _bStartFromDocument = false;
223 }
224
225 internal bool IsInReadingStates()
226 {
227 return _readState == ReadState.Interactive;
228 }
229
230 public override string? GetAttribute(string name)
231 {
232 if (!IsInReadingStates())
233 {
234 return null;
235 }
236 return _readerNav.GetAttribute(name);
237 }
238
239 public override string? GetAttribute(string name, string? namespaceURI)
240 {
241 if (!IsInReadingStates())
242 {
243 return null;
244 }
245 string ns = ((namespaceURI == null) ? string.Empty : namespaceURI);
246 return _readerNav.GetAttribute(name, ns);
247 }
248
249 public override string GetAttribute(int attributeIndex)
250 {
251 if (!IsInReadingStates())
252 {
253 throw new ArgumentOutOfRangeException("attributeIndex");
254 }
256 }
257
258 public override bool MoveToAttribute(string name)
259 {
260 if (!IsInReadingStates())
261 {
262 return false;
263 }
265 if (_readerNav.MoveToAttribute(name))
266 {
267 _curDepth++;
269 if (_bInReadBinary)
270 {
272 }
273 return true;
274 }
276 return false;
277 }
278
279 public override bool MoveToAttribute(string name, string? namespaceURI)
280 {
281 if (!IsInReadingStates())
282 {
283 return false;
284 }
286 string namespaceURI2 = ((namespaceURI == null) ? string.Empty : namespaceURI);
288 {
289 _curDepth++;
291 if (_bInReadBinary)
292 {
294 }
295 return true;
296 }
298 return false;
299 }
300
301 public override void MoveToAttribute(int attributeIndex)
302 {
303 if (!IsInReadingStates())
304 {
305 throw new ArgumentOutOfRangeException("attributeIndex");
306 }
308 try
309 {
310 if (AttributeCount <= 0)
311 {
312 throw new ArgumentOutOfRangeException("attributeIndex");
313 }
315 if (_bInReadBinary)
316 {
318 }
319 }
320 catch
321 {
323 throw;
324 }
325 _curDepth++;
327 }
328
329 public override bool MoveToFirstAttribute()
330 {
331 if (!IsInReadingStates())
332 {
333 return false;
334 }
336 if (AttributeCount > 0)
337 {
339 _curDepth++;
341 if (_bInReadBinary)
342 {
344 }
345 return true;
346 }
348 return false;
349 }
350
351 public override bool MoveToNextAttribute()
352 {
353 if (!IsInReadingStates() || _nodeType == XmlNodeType.EndElement)
354 {
355 return false;
356 }
360 {
362 if (_bInReadBinary)
363 {
365 }
366 return true;
367 }
369 return false;
370 }
371
372 public override bool MoveToElement()
373 {
374 if (!IsInReadingStates())
375 {
376 return false;
377 }
381 {
382 _curDepth--;
384 if (_bInReadBinary)
385 {
387 }
388 return true;
389 }
391 return false;
392 }
393
394 public override bool Read()
395 {
396 return Read(fSkipChildren: false);
397 }
398
399 private bool Read(bool fSkipChildren)
400 {
401 if (_fEOF)
402 {
403 return false;
404 }
405 if (_readState == ReadState.Initial)
406 {
407 if (_readerNav.NodeType == XmlNodeType.Document || _readerNav.NodeType == XmlNodeType.DocumentFragment)
408 {
409 _bStartFromDocument = true;
411 {
412 _readState = ReadState.Error;
413 return false;
414 }
415 }
417 _readState = ReadState.Interactive;
419 _curDepth = 0;
420 return true;
421 }
422 if (_bInReadBinary)
423 {
425 }
426 bool flag = false;
428 {
429 return false;
430 }
433 {
434 return true;
435 }
436 if (_readState == ReadState.Initial || _readState == ReadState.Interactive)
437 {
438 _readState = ReadState.Error;
439 }
440 if (_readState == ReadState.EndOfFile)
441 {
442 _nodeType = XmlNodeType.None;
443 }
444 return false;
445 }
446
447 private bool ReadNextNode(bool fSkipChildren)
448 {
449 if (_readState != ReadState.Interactive && _readState != 0)
450 {
451 _nodeType = XmlNodeType.None;
452 return false;
453 }
454 bool flag = !fSkipChildren;
456 if (flag && _nodeType != XmlNodeType.EndElement && _nodeType != XmlNodeType.EndEntity && (nodeType == XmlNodeType.Element || (nodeType == XmlNodeType.EntityReference && _bResolveEntity) || ((_readerNav.NodeType == XmlNodeType.Document || _readerNav.NodeType == XmlNodeType.DocumentFragment) && _readState == ReadState.Initial)))
457 {
459 {
461 _curDepth++;
462 if (_bResolveEntity)
463 {
464 _bResolveEntity = false;
465 }
466 return true;
467 }
469 {
470 _nodeType = XmlNodeType.EndElement;
471 return true;
472 }
473 if (_readerNav.NodeType == XmlNodeType.EntityReference && _bResolveEntity)
474 {
475 _bResolveEntity = false;
476 _nodeType = XmlNodeType.EndEntity;
477 return true;
478 }
480 }
481 if (_readerNav.NodeType == XmlNodeType.EntityReference && _bResolveEntity)
482 {
484 {
486 _curDepth++;
487 }
488 else
489 {
490 _nodeType = XmlNodeType.EndEntity;
491 }
492 _bResolveEntity = false;
493 return true;
494 }
496 }
497
498 private void SetEndOfFile()
499 {
500 _fEOF = true;
501 _readState = ReadState.EndOfFile;
502 _nodeType = XmlNodeType.None;
503 }
504
506 {
508 {
509 _nodeType = XmlNodeType.EndElement;
510 return true;
511 }
512 SetEndOfFile();
513 return false;
514 }
515
516 private bool ReadForward(bool fSkipChildren)
517 {
518 if (_readState == ReadState.Error)
519 {
520 return false;
521 }
522 if (!_bStartFromDocument && _curDepth == 0)
523 {
525 }
527 {
529 return true;
530 }
531 if (_curDepth == 0)
532 {
534 }
536 {
537 if (_readerNav.NodeType == XmlNodeType.Element)
538 {
539 _curDepth--;
540 _nodeType = XmlNodeType.EndElement;
541 return true;
542 }
543 if (_readerNav.NodeType == XmlNodeType.EntityReference)
544 {
545 _curDepth--;
546 _nodeType = XmlNodeType.EndEntity;
547 return true;
548 }
549 return true;
550 }
551 return false;
552 }
553
558
559 public override void Close()
560 {
561 _readState = ReadState.Closed;
562 }
563
564 public override void Skip()
565 {
566 Read(fSkipChildren: true);
567 }
568
569 public override string ReadString()
570 {
571 if (NodeType == XmlNodeType.EntityReference && _bResolveEntity && !Read())
572 {
574 }
575 return base.ReadString();
576 }
577
578 public override string? LookupNamespace(string prefix)
579 {
580 if (!IsInReadingStates())
581 {
582 return null;
583 }
585 if (text != null && text.Length == 0)
586 {
587 return null;
588 }
589 return text;
590 }
591
592 public override void ResolveEntity()
593 {
594 if (!IsInReadingStates() || _nodeType != XmlNodeType.EntityReference)
595 {
597 }
598 _bResolveEntity = true;
599 }
600
601 public override bool ReadAttributeValue()
602 {
603 if (!IsInReadingStates())
604 {
605 return false;
606 }
608 {
609 _bInReadBinary = false;
610 return true;
611 }
612 return false;
613 }
614
615 public override int ReadContentAsBase64(byte[] buffer, int index, int count)
616 {
617 if (_readState != ReadState.Interactive)
618 {
619 return 0;
620 }
621 if (!_bInReadBinary)
622 {
624 }
625 _bInReadBinary = false;
627 _bInReadBinary = true;
628 return result;
629 }
630
631 public override int ReadContentAsBinHex(byte[] buffer, int index, int count)
632 {
633 if (_readState != ReadState.Interactive)
634 {
635 return 0;
636 }
637 if (!_bInReadBinary)
638 {
640 }
641 _bInReadBinary = false;
643 _bInReadBinary = true;
644 return result;
645 }
646
647 public override int ReadElementContentAsBase64(byte[] buffer, int index, int count)
648 {
649 if (_readState != ReadState.Interactive)
650 {
651 return 0;
652 }
653 if (!_bInReadBinary)
654 {
656 }
657 _bInReadBinary = false;
659 _bInReadBinary = true;
660 return result;
661 }
662
663 public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
664 {
665 if (_readState != ReadState.Interactive)
666 {
667 return 0;
668 }
669 if (!_bInReadBinary)
670 {
672 }
673 _bInReadBinary = false;
675 _bInReadBinary = true;
676 return result;
677 }
678
679 private void FinishReadBinary()
680 {
681 _bInReadBinary = false;
683 }
684
689
694
696 {
697 if (!IsInReadingStates())
698 {
700 }
702 if (text != null)
703 {
705 }
706 return text;
707 }
708}
static string Xnr_ResolveEntity
Definition SR.cs:1352
static string Xml_InvalidOperation
Definition SR.cs:18
Definition SR.cs:7
static ReadContentAsBinaryHelper CreateOrReset(ReadContentAsBinaryHelper helper, XmlReader reader)
int ReadContentAsBase64(byte[] buffer, int index, int count)
int ReadContentAsBinHex(byte[] buffer, int index, int count)
int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
int ReadElementContentAsBase64(byte[] buffer, int index, int count)
SchemaInfo? DtdSchemaInfo
string Add(char[] array, int offset, int length)
IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
bool ReadAttributeValue(ref int level, ref bool bResolveEntity, ref XmlNodeType nt)
string LookupPrefix(string namespaceName)
void ResetMove(ref int level, ref XmlNodeType nt)
bool ReadNextNode(bool fSkipChildren)
bool ReadAtZeroLevel(bool fSkipChildren)
override string ReadString()
override bool MoveToElement()
override bool ReadAttributeValue()
override void ResolveEntity()
override? string GetAttribute(string name)
bool ReadForward(bool fSkipChildren)
override bool MoveToNextAttribute()
override? string LookupNamespace(string prefix)
override XmlNodeType NodeType
override string LocalName
override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
readonly XmlNodeReaderNavigator _readerNav
override int ReadElementContentAsBase64(byte[] buffer, int index, int count)
override void MoveToAttribute(int attributeIndex)
ReadContentAsBinaryHelper _readBinaryHelper
override bool CanResolveEntity
override string NamespaceURI
override int ReadContentAsBinHex(byte[] buffer, int index, int count)
override bool MoveToAttribute(string name)
bool Read(bool fSkipChildren)
override string GetAttribute(int attributeIndex)
override bool CanReadBinaryContent
override? string GetAttribute(string name, string? namespaceURI)
override int ReadContentAsBase64(byte[] buffer, int index, int count)
override? IDtdInfo DtdInfo
override bool MoveToFirstAttribute()
override bool MoveToAttribute(string name, string? namespaceURI)
IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
string? LookupPrefix(string namespaceName)
string? LookupNamespace(string prefix)