Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlSchemaObjectTable.cs
Go to the documentation of this file.
3
4namespace System.Xml.Schema;
5
7{
8 internal enum EnumeratorType
9 {
10 Keys,
11 Values,
13 }
14
15 internal struct XmlSchemaObjectEntry
16 {
18
20
22 {
23 qname = name;
24 xso = value;
25 }
26 }
27
28 internal sealed class NamesCollection : ICollection, IEnumerable
29 {
31
32 private readonly int _size;
33
34 public int Count => _size;
35
36 public object SyncRoot => ((ICollection)_entries).SyncRoot;
37
38 public bool IsSynchronized => ((ICollection)_entries).IsSynchronized;
39
41 {
43 _size = size;
44 }
45
46 public void CopyTo(Array array, int arrayIndex)
47 {
48 if (array == null)
49 {
50 throw new ArgumentNullException("array");
51 }
52 if (arrayIndex < 0)
53 {
54 throw new ArgumentOutOfRangeException("arrayIndex");
55 }
56 for (int i = 0; i < _size; i++)
57 {
58 array.SetValue(_entries[i].qname, arrayIndex++);
59 }
60 }
61
63 {
64 return new XSOEnumerator(_entries, _size, EnumeratorType.Keys);
65 }
66 }
67
68 internal sealed class ValuesCollection : ICollection, IEnumerable
69 {
71
72 private readonly int _size;
73
74 public int Count => _size;
75
76 public object SyncRoot => ((ICollection)_entries).SyncRoot;
77
78 public bool IsSynchronized => ((ICollection)_entries).IsSynchronized;
79
81 {
83 _size = size;
84 }
85
86 public void CopyTo(Array array, int arrayIndex)
87 {
88 if (array == null)
89 {
90 throw new ArgumentNullException("array");
91 }
92 if (arrayIndex < 0)
93 {
94 throw new ArgumentOutOfRangeException("arrayIndex");
95 }
96 for (int i = 0; i < _size; i++)
97 {
98 array.SetValue(_entries[i].xso, arrayIndex++);
99 }
100 }
101
103 {
104 return new XSOEnumerator(_entries, _size, EnumeratorType.Values);
105 }
106 }
107
108 internal class XSOEnumerator : IEnumerator
109 {
111
112 private readonly EnumeratorType _enumType;
113
114 protected int currentIndex;
115
116 protected int size;
117
119
121
122 public object Current
123 {
124 get
125 {
126 if (currentIndex == -1)
127 {
129 }
130 if (currentIndex >= size)
131 {
133 }
134 return _enumType switch
135 {
139 _ => null,
140 };
141 }
142 }
143
151
152 public bool MoveNext()
153 {
154 if (currentIndex >= size - 1)
155 {
156 currentValue = null;
157 currentKey = null;
158 return false;
159 }
160 currentIndex++;
163 return true;
164 }
165
166 public void Reset()
167 {
168 currentIndex = -1;
169 currentValue = null;
170 currentKey = null;
171 }
172 }
173
175 {
177 {
178 get
179 {
180 if (currentIndex == -1)
181 {
183 }
184 if (currentIndex >= size)
185 {
187 }
189 }
190 }
191
192 public object Key
193 {
194 get
195 {
196 if (currentIndex == -1)
197 {
199 }
200 if (currentIndex >= size)
201 {
203 }
204 return currentKey;
205 }
206 }
207
208 public object Value
209 {
210 get
211 {
212 if (currentIndex == -1)
213 {
215 }
216 if (currentIndex >= size)
217 {
219 }
220 return currentValue;
221 }
222 }
223
228 }
229
231
233
234 public int Count => _table.Count;
235
237 {
238 get
239 {
240 if (_table.TryGetValue(name, out var value))
241 {
242 return value;
243 }
244 return null;
245 }
246 }
247
249
251
253 {
254 }
255
257 {
258 _table.Add(name, value);
260 }
261
263 {
264 XmlSchemaObject value2 = null;
265 if (_table.TryGetValue(name, out value2))
266 {
267 _table[name] = value;
270 }
271 else
272 {
273 Add(name, value);
274 }
275 }
276
278 {
279 if (_table.TryGetValue(name, out var value2))
280 {
281 _table[name] = value;
284 }
285 }
286
287 internal void Clear()
288 {
289 _table.Clear();
290 _entries.Clear();
291 }
292
293 internal void Remove(XmlQualifiedName name)
294 {
295 if (_table.TryGetValue(name, out var value))
296 {
297 _table.Remove(name);
299 _entries.RemoveAt(index);
300 }
301 }
302
304 {
305 for (int i = 0; i < _entries.Count; i++)
306 {
307 if (_entries[i].xso == xso)
308 {
309 return i;
310 }
311 }
312 return -1;
313 }
314
315 public bool Contains(XmlQualifiedName name)
316 {
317 return _table.ContainsKey(name);
318 }
319
321 {
322 return new XSODictionaryEnumerator(_entries, _table.Count, EnumeratorType.DictionaryEntry);
323 }
324}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Sch_EnumNotStarted
Definition SR.cs:1204
static string Sch_EnumFinished
Definition SR.cs:1206
Definition SR.cs:7
NamesCollection(List< XmlSchemaObjectEntry > entries, int size)
ValuesCollection(List< XmlSchemaObjectEntry > entries, int size)
XSODictionaryEnumerator(List< XmlSchemaObjectEntry > entries, int size, EnumeratorType enumType)
XSOEnumerator(List< XmlSchemaObjectEntry > entries, int size, EnumeratorType enumType)
readonly List< XmlSchemaObjectEntry > _entries
readonly Dictionary< XmlQualifiedName, XmlSchemaObject > _table
void Insert(XmlQualifiedName name, XmlSchemaObject value)
void Add(XmlQualifiedName name, XmlSchemaObject value)
void Replace(XmlQualifiedName name, XmlSchemaObject value)
XmlSchemaObjectEntry(XmlQualifiedName name, XmlSchemaObject value)