Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlAttributeCollection.cs
Go to the documentation of this file.
4
5namespace System.Xml;
6
8{
9 [IndexerName("ItemOf")]
10 public XmlAttribute this[int i]
11 {
12 get
13 {
14 try
15 {
16 return (XmlAttribute)nodes[i];
17 }
19 {
21 }
22 }
23 }
24
25 [IndexerName("ItemOf")]
26 public XmlAttribute? this[string name]
27 {
28 get
29 {
30 int hashCode = XmlName.GetHashCode(name);
31 for (int i = 0; i < nodes.Count; i++)
32 {
34 if (hashCode == xmlAttribute.LocalNameHash && name == xmlAttribute.Name)
35 {
36 return xmlAttribute;
37 }
38 }
39 return null;
40 }
41 }
42
43 [IndexerName("ItemOf")]
44 public XmlAttribute? this[string localName, string? namespaceURI]
45 {
46 get
47 {
48 int hashCode = XmlName.GetHashCode(localName);
49 for (int i = 0; i < nodes.Count; i++)
50 {
52 if (hashCode == xmlAttribute.LocalNameHash && localName == xmlAttribute.LocalName && namespaceURI == xmlAttribute.NamespaceURI)
53 {
54 return xmlAttribute;
55 }
56 }
57 return null;
58 }
59 }
60
62
63 object ICollection.SyncRoot => this;
64
66
68 : base(parent)
69 {
70 }
71
73 {
74 for (int i = 0; i < nodes.Count; i++)
75 {
77 if (xmlAttribute.LocalNameHash == node.LocalNameHash && xmlAttribute.LocalName == node.LocalName && xmlAttribute.NamespaceURI == node.NamespaceURI)
78 {
79 return i;
80 }
81 }
82 return -1;
83 }
84
85 [return: NotNullIfNotNull("node")]
86 public override XmlNode? SetNamedItem(XmlNode? node)
87 {
88 if (node == null)
89 {
90 return null;
91 }
92 if (!(node is XmlAttribute))
93 {
95 }
96 int num = FindNodeOffset(node.LocalName, node.NamespaceURI);
97 if (num == -1)
98 {
100 }
101 XmlNode result = base.RemoveNodeAt(num);
102 InsertNodeAt(num, node);
103 return result;
104 }
105
107 {
108 if (node.OwnerDocument != null && node.OwnerDocument != parent.OwnerDocument)
109 {
111 }
112 if (node.OwnerElement != null)
113 {
114 Detach(node);
115 }
117 InsertNodeAt(0, node);
118 return node;
119 }
120
122 {
124 if (ownerDocument == null || !ownerDocument.IsLoading)
125 {
127 {
129 }
130 if (node.OwnerElement != null)
131 {
132 Detach(node);
133 }
134 AddNode(node);
135 }
136 else
137 {
138 base.AddNodeForLoad(node, ownerDocument);
140 }
141 return node;
142 }
143
145 {
146 if (newNode == refNode)
147 {
148 return newNode;
149 }
150 if (refNode == null)
151 {
152 return Append(newNode);
153 }
154 if (refNode.OwnerElement != parent)
155 {
157 }
158 if (newNode.OwnerDocument != null && newNode.OwnerDocument != parent.OwnerDocument)
159 {
161 }
162 if (newNode.OwnerElement != null)
163 {
165 }
166 int num = FindNodeOffset(refNode.LocalName, refNode.NamespaceURI);
168 if (num2 >= 0 && num2 < num)
169 {
170 num--;
171 }
172 InsertNodeAt(num, newNode);
173 return newNode;
174 }
175
177 {
178 if (newNode == refNode)
179 {
180 return newNode;
181 }
182 if (refNode == null)
183 {
184 return Prepend(newNode);
185 }
186 if (refNode.OwnerElement != parent)
187 {
189 }
190 if (newNode.OwnerDocument != null && newNode.OwnerDocument != parent.OwnerDocument)
191 {
193 }
194 if (newNode.OwnerElement != null)
195 {
197 }
198 int num = FindNodeOffset(refNode.LocalName, refNode.NamespaceURI);
200 if (num2 >= 0 && num2 <= num)
201 {
202 num--;
203 }
204 InsertNodeAt(num + 1, newNode);
205 return newNode;
206 }
207
209 {
210 int count = nodes.Count;
211 for (int i = 0; i < count; i++)
212 {
213 if (nodes[i] == node)
214 {
215 RemoveNodeAt(i);
216 return node;
217 }
218 }
219 return null;
220 }
221
222 public XmlAttribute? RemoveAt(int i)
223 {
224 if (i < 0 || i >= Count)
225 {
226 return null;
227 }
228 return (XmlAttribute)RemoveNodeAt(i);
229 }
230
231 public void RemoveAll()
232 {
233 int num = Count;
234 while (num > 0)
235 {
236 num--;
237 RemoveAt(num);
238 }
239 }
240
242 {
243 int num = 0;
244 int count = Count;
245 while (num < count)
246 {
247 array.SetValue(nodes[num], index);
248 num++;
249 index++;
250 }
251 }
252
253 public void CopyTo(XmlAttribute[] array, int index)
254 {
255 int num = 0;
256 int count = Count;
257 while (num < count)
258 {
259 array[index] = (XmlAttribute)((XmlNode)nodes[num]).CloneNode(deep: true);
260 num++;
261 index++;
262 }
263 }
264
265 internal override XmlNode AddNode(XmlNode node)
266 {
268 XmlNode result = base.AddNode(node);
270 return result;
271 }
272
273 internal override XmlNode InsertNodeAt(int i, XmlNode node)
274 {
275 XmlNode result = base.InsertNodeAt(i, node);
277 return result;
278 }
279
280 internal override XmlNode RemoveNodeAt(int i)
281 {
282 XmlNode xmlNode = base.RemoveNodeAt(i);
285 if (defaultAttribute != null)
286 {
288 }
289 return xmlNode;
290 }
291
292 internal void Detach(XmlAttribute attr)
293 {
294 attr.OwnerElement.Attributes.Remove(attr);
295 }
296
298 {
300 {
302 if (iDInfoByElement != null && iDInfoByElement.Prefix == attr.XmlName.Prefix && iDInfoByElement.LocalName == attr.XmlName.LocalName)
303 {
305 }
306 }
307 }
308
310 {
312 {
314 if (iDInfoByElement != null && iDInfoByElement.Prefix == attr.XmlName.Prefix && iDInfoByElement.LocalName == attr.XmlName.LocalName)
315 {
317 }
318 }
319 }
320
322 {
323 int num = FindNodeOffset(attr.LocalName, attr.NamespaceURI);
324 if (num != -1)
325 {
327 base.RemoveNodeAt(num);
329 }
330 return num;
331 }
332
334 {
337 XmlName iDInfoByElement = ownerDocument.GetIDInfoByElement(xmlElement.XmlName);
338 if (iDInfoByElement != null && iDInfoByElement.Prefix == attrPrefix && iDInfoByElement.LocalName == attrLocalName)
339 {
340 return true;
341 }
342 return false;
343 }
344
352
359}
static string Xdom_NamedNode_Context
Definition SR.cs:1286
static string Xdom_AttrCol_Object
Definition SR.cs:1282
static string Xdom_IndexOutOfRange
Definition SR.cs:1312
static string Xdom_AttrCol_Insert
Definition SR.cs:1284
Definition SR.cs:7
override XmlNode AddNode(XmlNode node)
void CopyTo(XmlAttribute[] array, int index)
void InsertParentIntoElementIdAttrMap(XmlAttribute attr)
override? XmlNode SetNamedItem(XmlNode? node)
void ResetParentInElementIdAttrMap(string oldVal, string newVal)
int RemoveDuplicateAttribute(XmlAttribute attr)
XmlAttribute InternalAppendAttribute(XmlAttribute node)
XmlAttribute? Remove(XmlAttribute? node)
bool PrepareParentInElementIdAttrMap(string attrPrefix, string attrLocalName)
XmlAttribute Prepend(XmlAttribute node)
override XmlNode InsertNodeAt(int i, XmlNode node)
XmlAttribute InsertAfter(XmlAttribute newNode, XmlAttribute? refNode)
XmlAttribute Append(XmlAttribute node)
XmlAttribute InsertBefore(XmlAttribute newNode, XmlAttribute? refNode)
void RemoveParentFromElementIdAttrMap(XmlAttribute attr)
void AddElementWithId(string id, XmlElement elem)
override? XmlDocument OwnerDocument
XmlAttribute GetDefaultAttribute(XmlElement elem, string attrPrefix, string attrLocalname, string attrNamespaceURI)
XmlName GetIDInfoByElement(XmlName eleName)
void RemoveElementWithId(string id, XmlElement elem)
static int GetHashCode(string name)
Definition XmlName.cs:103
int FindNodeOffset(string name)
virtual ? XmlDocument OwnerDocument
Definition XmlNode.cs:109
virtual string Prefix
Definition XmlNode.cs:142
void CopyTo(Array array, int index)