Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XPathNodeInfoAtom.cs
Go to the documentation of this file.
1using System;
3using System.Text;
5
7
8internal sealed class XPathNodeInfoAtom : IEquatable<XPathNodeInfoAtom>
9{
10 private string _localName;
11
12 private string _namespaceUri;
13
14 private string _prefix;
15
16 private string _baseUri;
17
19
21
23
25
26 private int _lineNumBase;
27
28 private int _linePosBase;
29
30 private int _hashCode;
31
32 private int _localNameHash;
33
35
37
39
40 public string LocalName => _localName;
41
42 public string NamespaceUri => _namespaceUri;
43
44 public string Prefix => _prefix;
45
46 public string BaseUri => _baseUri;
47
49
51
53
55
57
59
61
63 {
64 get
65 {
66 return _next;
67 }
68 set
69 {
70 _next = value;
71 }
72 }
73
75 {
76 _pageInfo = pageInfo;
77 }
78
79 public XPathNodeInfoAtom(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase)
80 {
81 Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase);
82 }
83
84 public void Init(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase)
85 {
86 _localName = localName;
87 _namespaceUri = namespaceUri;
89 _baseUri = baseUri;
90 _pageParent = pageParent;
91 _pageSibling = pageSibling;
92 _pageSimilar = pageSimilar;
93 _doc = doc;
94 _lineNumBase = lineNumBase;
95 _linePosBase = linePosBase;
96 _next = null;
97 _pageInfo = null;
98 _hashCode = 0;
100 for (int i = 0; i < _localName.Length; i++)
101 {
103 }
104 }
105
106 public override int GetHashCode()
107 {
108 if (_hashCode == 0)
109 {
110 int num = _localNameHash;
111 if (_pageSibling != null)
112 {
113 num += (num << 7) ^ _pageSibling[0].PageInfo.PageNumber;
114 }
115 if (_pageParent != null)
116 {
117 num += (num << 7) ^ _pageParent[0].PageInfo.PageNumber;
118 }
119 if (_pageSimilar != null)
120 {
121 num += (num << 7) ^ _pageSimilar[0].PageInfo.PageNumber;
122 }
123 _hashCode = ((num == 0) ? 1 : num);
124 }
125 return _hashCode;
126 }
127
128 public override bool Equals([NotNullWhen(true)] object other)
129 {
130 return Equals(other as XPathNodeInfoAtom);
131 }
132
134 {
135 if (GetHashCode() == other.GetHashCode() && (object)_localName == other._localName && _pageSibling == other._pageSibling && (object)_namespaceUri == other._namespaceUri && _pageParent == other._pageParent && _pageSimilar == other._pageSimilar && (object)_prefix == other._prefix && (object)_baseUri == other._baseUri && _lineNumBase == other._lineNumBase && _linePosBase == other._linePosBase)
136 {
137 return true;
138 }
139 return false;
140 }
141
142 public override string ToString()
143 {
144 StringBuilder stringBuilder = new StringBuilder();
145 stringBuilder.Append("hash=");
146 stringBuilder.Append(GetHashCode());
147 stringBuilder.Append(", ");
148 if (_localName.Length != 0)
149 {
150 stringBuilder.Append('{');
151 stringBuilder.Append(_namespaceUri);
152 stringBuilder.Append('}');
153 if (_prefix.Length != 0)
154 {
155 stringBuilder.Append(_prefix);
156 stringBuilder.Append(':');
157 }
158 stringBuilder.Append(_localName);
159 stringBuilder.Append(", ");
160 }
161 if (_pageParent != null)
162 {
163 stringBuilder.Append("parent=");
164 stringBuilder.Append(_pageParent[0].PageInfo.PageNumber);
165 stringBuilder.Append(", ");
166 }
167 if (_pageSibling != null)
168 {
169 stringBuilder.Append("sibling=");
170 stringBuilder.Append(_pageSibling[0].PageInfo.PageNumber);
171 stringBuilder.Append(", ");
172 }
173 if (_pageSimilar != null)
174 {
175 stringBuilder.Append("similar=");
176 stringBuilder.Append(_pageSimilar[0].PageInfo.PageNumber);
177 stringBuilder.Append(", ");
178 }
179 stringBuilder.Append("lineNum=");
180 stringBuilder.Append(_lineNumBase);
181 stringBuilder.Append(", ");
182 stringBuilder.Append("linePos=");
183 stringBuilder.Append(_linePosBase);
184 return stringBuilder.ToString();
185 }
186}
XPathNodeInfoAtom(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase)
override bool Equals([NotNullWhen(true)] object other)
void Init(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase)
XPathNodeInfoAtom(XPathNodePageInfo pageInfo)
bool Equals(XPathNodeInfoAtom other)
override string ToString()
StringBuilder Append(char value, int repeatCount)