Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XPathDocumentNavigator.cs
Go to the documentation of this file.
2using System.Text;
3using System.Xml;
5
7
9{
11
13
14 private int _idxCurrent;
15
16 private int _idxParent;
17
18 private string _atomizedLocalName;
19
20 public override string Value
21 {
22 get
23 {
24 string value = _pageCurrent[_idxCurrent].Value;
25 if (value != null)
26 {
27 return value;
28 }
29 if (_idxParent != 0)
30 {
32 }
33 string text = string.Empty;
37 int idxNode;
40 {
41 pageNode = null;
42 idxNode = 0;
43 }
45 {
46 value = pageCurrent[idxCurrent].Value;
47 if (text.Length == 0)
48 {
49 text = value;
50 continue;
51 }
52 if (stringBuilder == null)
53 {
55 stringBuilder.Append(text);
56 }
57 stringBuilder.Append(value);
58 }
59 if (stringBuilder == null)
60 {
61 return text;
62 }
63 return stringBuilder.ToString();
64 }
65 }
66
68
69 public override string LocalName => _pageCurrent[_idxCurrent].LocalName;
70
72
73 public override string Name => _pageCurrent[_idxCurrent].Name;
74
75 public override string Prefix => _pageCurrent[_idxCurrent].Prefix;
76
77 public override string BaseURI
78 {
79 get
80 {
82 int num;
83 if (_idxParent != 0)
84 {
86 num = _idxParent;
87 }
88 else
89 {
91 num = _idxCurrent;
92 }
93 do
94 {
95 XPathNodeType nodeType = pageNode[num].NodeType;
96 if ((uint)nodeType <= 1u || nodeType == XPathNodeType.ProcessingInstruction)
97 {
98 return pageNode[num].BaseUri;
99 }
100 num = pageNode[num].GetParent(out pageNode);
101 }
102 while (num != 0);
103 return string.Empty;
104 }
105 }
106
108
110
112
114
115 internal override string UniqueId
116 {
117 get
118 {
119 char[] array = new char[16];
120 int length = 0;
122 int num;
123 if (_idxParent != 0)
124 {
125 num = (_pageParent[0].PageInfo.PageNumber - 1 << 16) | (_idxParent - 1);
126 do
127 {
128 array[length++] = XPathNavigator.UniqueIdTbl[num & 0x1F];
129 num >>= 5;
130 }
131 while (num != 0);
132 array[length++] = '0';
133 }
134 num = (_pageCurrent[0].PageInfo.PageNumber - 1 << 16) | (_idxCurrent - 1);
135 do
136 {
137 array[length++] = XPathNavigator.UniqueIdTbl[num & 0x1F];
138 num >>= 5;
139 }
140 while (num != 0);
141 return new string(array, 0, length);
142 }
143 }
144
145 public override object UnderlyingObject => Clone();
146
147 public int LineNumber
148 {
149 get
150 {
151 if (_idxParent != 0 && NodeType == XPathNodeType.Text)
152 {
154 }
156 }
157 }
158
159 public int LinePosition
160 {
161 get
162 {
163 if (_idxParent != 0 && NodeType == XPathNodeType.Text)
164 {
166 }
168 }
169 }
170
178
184
189
190 public override bool MoveToFirstAttribute()
191 {
195 {
198 return true;
199 }
200 return false;
201 }
202
203 public override bool MoveToNextAttribute()
204 {
206 }
207
208 public override bool MoveToAttribute(string localName, string namespaceURI)
209 {
212 if ((object)localName != _atomizedLocalName)
213 {
214 _atomizedLocalName = ((localName != null) ? NameTable.Get(localName) : null);
215 }
217 {
220 return true;
221 }
222 return false;
223 }
224
226 {
229 {
230 if (namespaceScope != XPathNamespaceScope.ExcludeXml || !pageNmsp[num].IsXmlNamespaceNode)
231 {
235 _idxCurrent = num;
236 return true;
237 }
238 }
239 return false;
240 }
241
242 public override bool MoveToNextNamespace(XPathNamespaceScope scope)
243 {
245 int num = _idxCurrent;
246 if (pageNode[num].NodeType != XPathNodeType.Namespace)
247 {
248 return false;
249 }
250 do
251 {
252 num = pageNode[num].GetSibling(out pageNode);
253 if (num == 0)
254 {
255 return false;
256 }
257 switch (scope)
258 {
259 case XPathNamespaceScope.Local:
260 {
262 int parent = pageNode[num].GetParent(out pageNode2);
263 if (parent != _idxParent || pageNode2 != _pageParent)
264 {
265 return false;
266 }
267 break;
268 }
269 case XPathNamespaceScope.ExcludeXml:
270 continue;
271 }
272 break;
273 }
274 while (pageNode[num].IsXmlNamespaceNode);
276 _idxCurrent = num;
277 return true;
278 }
279
280 public override bool MoveToNext()
281 {
283 }
284
285 public override bool MoveToPrevious()
286 {
287 if (_idxParent != 0)
288 {
289 return false;
290 }
292 }
293
294 public override bool MoveToFirstChild()
295 {
296 if (_pageCurrent[_idxCurrent].HasCollapsedText)
297 {
301 return true;
302 }
304 }
305
306 public override bool MoveToParent()
307 {
308 if (_idxParent != 0)
309 {
312 _pageParent = null;
313 _idxParent = 0;
314 return true;
315 }
317 }
318
319 public override bool MoveTo(XPathNavigator other)
320 {
322 {
327 return true;
328 }
329 return false;
330 }
331
332 public override bool MoveToId(string id)
333 {
336 if (num != 0)
337 {
339 _idxCurrent = num;
340 _pageParent = null;
341 _idxParent = 0;
342 return true;
343 }
344 return false;
345 }
346
347 public override bool IsSamePosition(XPathNavigator other)
348 {
350 {
351 if (_idxCurrent == xPathDocumentNavigator._idxCurrent && _pageCurrent == xPathDocumentNavigator._pageCurrent && _idxParent == xPathDocumentNavigator._idxParent)
352 {
353 return _pageParent == xPathDocumentNavigator._pageParent;
354 }
355 return false;
356 }
357 return false;
358 }
359
360 public override void MoveToRoot()
361 {
362 if (_idxParent != 0)
363 {
364 _pageParent = null;
365 _idxParent = 0;
366 }
368 }
369
370 public override bool MoveToChild(string localName, string namespaceURI)
371 {
372 if ((object)localName != _atomizedLocalName)
373 {
374 _atomizedLocalName = ((localName != null) ? NameTable.Get(localName) : null);
375 }
377 }
378
379 public override bool MoveToNext(string localName, string namespaceURI)
380 {
381 if ((object)localName != _atomizedLocalName)
382 {
383 _atomizedLocalName = ((localName != null) ? NameTable.Get(localName) : null);
384 }
386 }
387
388 public override bool MoveToChild(XPathNodeType type)
389 {
390 if (_pageCurrent[_idxCurrent].HasCollapsedText)
391 {
392 if (type != XPathNodeType.Text && type != XPathNodeType.All)
393 {
394 return false;
395 }
399 return true;
400 }
402 }
403
404 public override bool MoveToNext(XPathNodeType type)
405 {
407 }
408
409 public override bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end)
410 {
411 if ((object)localName != _atomizedLocalName)
412 {
413 _atomizedLocalName = ((localName != null) ? NameTable.Get(localName) : null);
414 }
417 if (_idxParent != 0)
418 {
420 {
421 return false;
422 }
425 _pageParent = null;
426 _idxParent = 0;
427 return true;
428 }
430 }
431
432 public override bool MoveToFollowing(XPathNodeType type, XPathNavigator end)
433 {
436 int followingEnd;
437 if (type == XPathNodeType.Text || type == XPathNodeType.All)
438 {
439 if (_pageCurrent[_idxCurrent].HasCollapsedText)
440 {
442 {
443 return false;
444 }
448 return true;
449 }
450 if (type == XPathNodeType.Text)
451 {
454 int idxCurrent;
455 if (_idxParent != 0)
456 {
459 }
460 else
461 {
464 }
466 {
467 return false;
468 }
470 {
471 return false;
472 }
474 {
475 _idxCurrent = pageCurrent[idxCurrent].Document.GetCollapsedTextNode(out _pageCurrent);
478 }
479 else
480 {
483 _pageParent = null;
484 _idxParent = 0;
485 }
486 return true;
487 }
488 }
490 if (_idxParent != 0)
491 {
493 {
494 return false;
495 }
498 _pageParent = null;
499 _idxParent = 0;
500 return true;
501 }
503 }
504
506 {
507 return new XPathDocumentKindChildIterator(this, type);
508 }
509
510 public override XPathNodeIterator SelectChildren(string name, string namespaceURI)
511 {
512 if (name.Length == 0)
513 {
514 return base.SelectChildren(name, namespaceURI);
515 }
516 return new XPathDocumentElementChildIterator(this, name, namespaceURI);
517 }
518
519 public override XPathNodeIterator SelectDescendants(XPathNodeType type, bool matchSelf)
520 {
521 return new XPathDocumentKindDescendantIterator(this, type, matchSelf);
522 }
523
524 public override XPathNodeIterator SelectDescendants(string name, string namespaceURI, bool matchSelf)
525 {
526 if (name.Length == 0)
527 {
528 return base.SelectDescendants(name, namespaceURI, matchSelf);
529 }
530 return new XPathDocumentElementDescendantIterator(this, name, namespaceURI, matchSelf);
531 }
532
534 {
536 {
538 XPathDocument document2 = xPathDocumentNavigator._pageCurrent[xPathDocumentNavigator._idxCurrent].Document;
539 if (document == document2)
540 {
541 int num = GetPrimaryLocation();
542 int num2 = xPathDocumentNavigator.GetPrimaryLocation();
543 if (num == num2)
544 {
545 num = GetSecondaryLocation();
546 num2 = xPathDocumentNavigator.GetSecondaryLocation();
547 if (num == num2)
548 {
549 return XmlNodeOrder.Same;
550 }
551 }
552 if (num >= num2)
553 {
554 return XmlNodeOrder.After;
555 }
556 return XmlNodeOrder.Before;
557 }
558 }
559 return XmlNodeOrder.Unknown;
560 }
561
562 public override bool IsDescendant([NotNullWhen(true)] XPathNavigator other)
563 {
565 {
567 int num;
568 if (xPathDocumentNavigator._idxParent != 0)
569 {
570 pageNode = xPathDocumentNavigator._pageParent;
571 num = xPathDocumentNavigator._idxParent;
572 }
573 else
574 {
575 num = xPathDocumentNavigator._pageCurrent[xPathDocumentNavigator._idxCurrent].GetParent(out pageNode);
576 }
577 while (num != 0)
578 {
579 if (num == _idxCurrent && pageNode == _pageCurrent)
580 {
581 return true;
582 }
583 num = pageNode[num].GetParent(out pageNode);
584 }
585 }
586 return false;
587 }
588
589 private int GetPrimaryLocation()
590 {
591 if (_idxParent == 0)
592 {
594 }
596 }
597
599 {
600 if (_idxParent == 0)
601 {
602 return int.MinValue;
603 }
604 return _pageCurrent[_idxCurrent].NodeType switch
605 {
608 _ => int.MaxValue,
609 };
610 }
611
612 public bool HasLineInfo()
613 {
615 }
616
618 {
619 return _idxCurrent ^ _idxParent;
620 }
621
622 public bool IsElementMatch(string localName, string namespaceURI)
623 {
624 if ((object)localName != _atomizedLocalName)
625 {
626 _atomizedLocalName = ((localName != null) ? NameTable.Get(localName) : null);
627 }
628 if (_idxParent != 0)
629 {
630 return false;
631 }
633 }
634
636 {
637 return ((1 << (int)_pageCurrent[_idxCurrent].NodeType) & XPathNavigator.GetKindMask(typ)) != 0;
638 }
639
641 {
642 if (end != null && _pageCurrent[_idxCurrent].Document == end._pageCurrent[end._idxCurrent].Document)
643 {
644 if (end._idxParent == 0)
645 {
646 pageEnd = end._pageCurrent;
647 return end._idxCurrent;
648 }
649 pageEnd = end._pageParent;
651 {
652 return end._idxParent + 1;
653 }
654 return end._idxParent;
655 }
656 pageEnd = null;
657 return 0;
658 }
659}
override bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end)
override bool MoveToChild(string localName, string namespaceURI)
bool IsElementMatch(string localName, string namespaceURI)
override XPathNodeIterator SelectDescendants(XPathNodeType type, bool matchSelf)
override XPathNodeIterator SelectChildren(XPathNodeType type)
override bool IsDescendant([NotNullWhen(true)] XPathNavigator other)
override bool MoveToAttribute(string localName, string namespaceURI)
XPathDocumentNavigator(XPathNode[] pageCurrent, int idxCurrent, XPathNode[] pageParent, int idxParent)
override bool MoveToNext(string localName, string namespaceURI)
override XPathNodeIterator SelectChildren(string name, string namespaceURI)
override XmlNodeOrder ComparePosition(XPathNavigator other)
override XPathNodeIterator SelectDescendants(string name, string namespaceURI, bool matchSelf)
override bool IsSamePosition(XPathNavigator other)
int GetFollowingEnd(XPathDocumentNavigator end, bool useParentOfVirtual, out XPathNode[] pageEnd)
override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
override bool MoveToFollowing(XPathNodeType type, XPathNavigator end)
override bool MoveToNextNamespace(XPathNamespaceScope scope)
static bool GetNextAttribute(ref XPathNode[] pageNode, ref int idxNode)
static bool GetElementSibling(ref XPathNode[] pageNode, ref int idxNode, string localName, string namespaceName)
static bool GetTextFollowing(ref XPathNode[] pageCurrent, ref int idxCurrent, XPathNode[] pageEnd, int idxEnd)
static int GetInScopeNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp)
static bool GetPreviousContentSibling(ref XPathNode[] pageNode, ref int idxNode)
static int GetLocalNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp)
static bool GetFirstAttribute(ref XPathNode[] pageNode, ref int idxNode)
static bool GetElementChild(ref XPathNode[] pageNode, ref int idxNode, string localName, string namespaceName)
static bool GetContentFollowing(ref XPathNode[] pageCurrent, ref int idxCurrent, XPathNode[] pageEnd, int idxEnd, XPathNodeType typ)
static bool GetContentChild(ref XPathNode[] pageNode, ref int idxNode)
static bool GetNonDescendant(ref XPathNode[] pageNode, ref int idxNode)
static bool GetElementFollowing(ref XPathNode[] pageCurrent, ref int idxCurrent, XPathNode[] pageEnd, int idxEnd, string localName, string namespaceName)
static bool GetContentSibling(ref XPathNode[] pageNode, ref int idxNode)
static int GetLocation(XPathNode[] pageNode, int idxNode)
static bool GetParent(ref XPathNode[] pageNode, ref int idxNode)
static bool GetAttribute(ref XPathNode[] pageNode, ref int idxNode, string localName, string namespaceName)
override? string Get(string value)
Definition NameTable.cs:79
int LookupIdElement(string id, out XPathNode[] pageElem)
int GetCollapsedTextNode(out XPathNode[] pageText)
static readonly char[] NodeTypeLetter
static int GetKindMask(XPathNodeType type)
static readonly char[] UniqueIdTbl
XPathNodePageInfo PageInfo
Definition XPathNode.cs:51
int GetParent(out XPathNode[] pageNode)
Definition XPathNode.cs:121
int GetRoot(out XPathNode[] pageNode)
Definition XPathNode.cs:116
bool ElementMatch(string localName, string namespaceName)
Definition XPathNode.cs:148