Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlSchemaCollection.cs
Go to the documentation of this file.
2
3namespace System.Xml.Schema;
4
5[Obsolete("XmlSchemaCollection has been deprecated. Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation instead.")]
7{
8 private readonly Hashtable _collection;
9
10 private readonly XmlNameTable _nameTable;
11
13
14 private readonly object _wLock;
15
16 private readonly bool _isThreadSafe = true;
17
18 private ValidationEventHandler _validationEventHandler;
19
21
22 public int Count => _collection.Count;
23
25
27 {
28 set
29 {
31 }
32 }
33
34 public XmlSchema? this[string? ns] => ((XmlSchemaCollectionNode)_collection[(ns != null) ? ns : string.Empty])?.Schema;
35
37
38 object ICollection.SyncRoot => this;
39
41
42 internal ValidationEventHandler? EventHandler
43 {
44 get
45 {
47 }
48 set
49 {
51 }
52 }
53
54 public event ValidationEventHandler ValidationEventHandler
55 {
56 add
57 {
59 }
60 remove
61 {
63 }
64 }
65
67 : this(new NameTable())
68 {
69 }
70
72 {
73 if (nametable == null)
74 {
75 throw new ArgumentNullException("nametable");
76 }
79 _xmlResolver = null;
80 _isThreadSafe = true;
81 if (_isThreadSafe)
82 {
83 _wLock = new object();
84 }
85 }
86
87 public XmlSchema? Add(string? ns, string uri)
88 {
89 if (uri == null || uri.Length == 0)
90 {
91 throw new ArgumentNullException("uri");
92 }
95 XmlSchema xmlSchema = null;
96 try
97 {
99 while (xmlTextReader.Read())
100 {
101 }
102 return xmlSchema;
103 }
104 finally
105 {
106 xmlTextReader.Close();
107 }
108 }
109
110 public XmlSchema? Add(string? ns, XmlReader reader)
111 {
112 return Add(ns, reader, _xmlResolver);
113 }
114
115 public XmlSchema? Add(string? ns, XmlReader reader, XmlResolver? resolver)
116 {
117 if (reader == null)
118 {
119 throw new ArgumentNullException("reader");
120 }
122 SchemaInfo schemaInfo = new SchemaInfo();
125 SchemaType schemaType;
126 try
127 {
128 schemaType = parser.Parse(reader, ns);
129 }
130 catch (XmlSchemaException e)
131 {
133 return null;
134 }
135 if (schemaType == SchemaType.XSD)
136 {
138 return Add(ns, schemaInfo, parser.XmlSchema, compile: true, resolver);
139 }
140 return Add(ns, parser.XdrSchema, null, compile: true, resolver);
141 }
142
144 {
145 return Add(schema, _xmlResolver);
146 }
147
149 {
150 if (schema == null)
151 {
152 throw new ArgumentNullException("schema");
153 }
154 SchemaInfo schemaInfo = new SchemaInfo();
156 return Add(schema.TargetNamespace, schemaInfo, schema, compile: true, resolver);
157 }
158
160 {
161 if (schema == null)
162 {
163 throw new ArgumentNullException("schema");
164 }
165 if (this != schema)
166 {
167 IDictionaryEnumerator enumerator = schema._collection.GetEnumerator();
168 while (enumerator.MoveNext())
169 {
172 }
173 }
174 }
175
177 {
178 if (schema == null)
179 {
180 throw new ArgumentNullException("schema");
181 }
182 return this[schema.TargetNamespace] != null;
183 }
184
185 public bool Contains(string? ns)
186 {
187 return _collection[(ns != null) ? ns : string.Empty] != null;
188 }
189
194
199
201 {
202 if (array == null)
203 {
204 throw new ArgumentNullException("array");
205 }
206 if (index < 0)
207 {
208 throw new ArgumentOutOfRangeException("index");
209 }
211 while (enumerator.MoveNext())
212 {
213 if (index == array.Length)
214 {
215 throw new ArgumentOutOfRangeException("index");
216 }
217 array.SetValue(enumerator.Current, index++);
218 }
219 }
220
221 public void CopyTo(XmlSchema[] array, int index)
222 {
223 if (array == null)
224 {
225 throw new ArgumentNullException("array");
226 }
227 if (index < 0)
228 {
229 throw new ArgumentOutOfRangeException("index");
230 }
232 while (enumerator.MoveNext())
233 {
234 XmlSchema current = enumerator.Current;
235 if (current != null)
236 {
237 if (index == array.Length)
238 {
239 throw new ArgumentOutOfRangeException("index");
240 }
241 array[index++] = enumerator.Current;
242 }
243 }
244 }
245
246 internal SchemaInfo GetSchemaInfo(string ns)
247 {
248 return ((XmlSchemaCollectionNode)_collection[(ns != null) ? ns : string.Empty])?.SchemaInfo;
249 }
250
252 {
253 if (_nameTable != nt)
254 {
255 return new SchemaNames(nt);
256 }
257 if (_schemaNames == null)
258 {
260 }
261 return _schemaNames;
262 }
263
264 internal XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile)
265 {
266 return Add(ns, schemaInfo, schema, compile, _xmlResolver);
267 }
268
269 private XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, XmlResolver resolver)
270 {
271 int num = 0;
272 if (schema != null)
273 {
274 if (schema.ErrorCount == 0 && compile)
275 {
276 if (!schema.CompileSchema(this, resolver, schemaInfo, ns, _validationEventHandler, _nameTable, CompileContentModel: true))
277 {
278 num = 1;
279 }
280 ns = ((schema.TargetNamespace == null) ? string.Empty : schema.TargetNamespace);
281 }
282 num += schema.ErrorCount;
283 }
284 else
285 {
286 num += schemaInfo.ErrorCount;
287 ns = NameTable.Add(ns);
288 }
289 if (num == 0)
290 {
296 return schema;
297 }
298 return null;
299 }
300
302 {
303 if (_collection[ns] != null)
304 {
306 }
307 _collection.Add(ns, node);
308 }
309
310 private void Add(string ns, XmlSchemaCollectionNode node)
311 {
312 if (_isThreadSafe)
313 {
314 lock (_wLock)
315 {
317 return;
318 }
319 }
321 }
322
324 {
325 if (_validationEventHandler != null)
326 {
328 return;
329 }
330 throw e;
331 }
332}
virtual void Remove(object key)
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
static Hashtable Synchronized(Hashtable table)
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static ? Delegate Combine(Delegate? a, Delegate? b)
Definition Delegate.cs:379
override string Add(string key)
Definition NameTable.cs:33
XmlSchema? Add(string? ns, string uri)
XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, XmlResolver resolver)
void SendValidationEvent(XmlSchemaException e)
void Add(XmlSchemaCollection schema)
void AddNonThreadSafe(string ns, XmlSchemaCollectionNode node)
XmlSchemaCollectionEnumerator GetEnumerator()
void Add(string ns, XmlSchemaCollectionNode node)
XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile)
XmlSchema? Add(string? ns, XmlReader reader, XmlResolver? resolver)
void CopyTo(XmlSchema[] array, int index)
SchemaNames GetSchemaNames(XmlNameTable nt)
XmlSchema? Add(string? ns, XmlReader reader)
XmlSchema? Add(XmlSchema schema, XmlResolver? resolver)
XmlNameTable NameTable
Definition XmlReader.cs:116
void CopyTo(Array array, int index)