Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlSchema.cs
Go to the documentation of this file.
4using System.IO;
7
8namespace System.Xml.Schema;
9
10[XmlRoot("schema", Namespace = "http://www.w3.org/2001/XMLSchema")]
12{
13 public const string Namespace = "http://www.w3.org/2001/XMLSchema";
14
15 public const string InstanceNamespace = "http://www.w3.org/2001/XMLSchema-instance";
16
18
20
22
24
25 private string _targetNs;
26
27 private string _version;
28
30
32
33 private string _id;
34
36
37 private bool _isCompiled;
38
39 private bool _isCompiledBySet;
40
41 private bool _isPreprocessed;
42
43 private bool _isRedefined;
44
45 private int _errorCount;
46
48
50
52
54
56
58
60
61 private static int s_globalIdCounter = -1;
62
64
66
67 private int _schemaId = -1;
68
69 private Uri _baseUri;
70
71 private bool _isChameleon;
72
73 private readonly Hashtable _ids = new Hashtable();
74
76
78
79 [XmlAttribute("attributeFormDefault")]
80 [DefaultValue(XmlSchemaForm.None)]
82 {
83 get
84 {
86 }
87 set
88 {
90 }
91 }
92
93 [XmlAttribute("blockDefault")]
94 [DefaultValue(XmlSchemaDerivationMethod.None)]
96 {
97 get
98 {
99 return _blockDefault;
100 }
101 set
102 {
104 }
105 }
106
107 [XmlAttribute("finalDefault")]
108 [DefaultValue(XmlSchemaDerivationMethod.None)]
110 {
111 get
112 {
113 return _finalDefault;
114 }
115 set
116 {
118 }
119 }
120
121 [XmlAttribute("elementFormDefault")]
122 [DefaultValue(XmlSchemaForm.None)]
124 {
125 get
126 {
127 return _elementFormDefault;
128 }
129 set
130 {
132 }
133 }
134
135 [XmlAttribute("targetNamespace", DataType = "anyURI")]
136 public string? TargetNamespace
137 {
138 get
139 {
140 return _targetNs;
141 }
142 set
143 {
145 }
146 }
147
148 [XmlAttribute("version", DataType = "token")]
149 public string? Version
150 {
151 get
152 {
153 return _version;
154 }
155 set
156 {
157 _version = value;
158 }
159 }
160
161 [XmlElement("include", typeof(XmlSchemaInclude))]
162 [XmlElement("import", typeof(XmlSchemaImport))]
163 [XmlElement("redefine", typeof(XmlSchemaRedefine))]
165
166 [XmlElement("annotation", typeof(XmlSchemaAnnotation))]
167 [XmlElement("attribute", typeof(XmlSchemaAttribute))]
168 [XmlElement("attributeGroup", typeof(XmlSchemaAttributeGroup))]
169 [XmlElement("complexType", typeof(XmlSchemaComplexType))]
170 [XmlElement("simpleType", typeof(XmlSchemaSimpleType))]
171 [XmlElement("element", typeof(XmlSchemaElement))]
172 [XmlElement("group", typeof(XmlSchemaGroup))]
173 [XmlElement("notation", typeof(XmlSchemaNotation))]
175
176 [XmlIgnore]
177 public bool IsCompiled
178 {
179 get
180 {
181 if (!_isCompiled)
182 {
183 return _isCompiledBySet;
184 }
185 return true;
186 }
187 }
188
189 [XmlIgnore]
190 internal bool IsCompiledBySet
191 {
192 get
193 {
194 return _isCompiledBySet;
195 }
196 set
197 {
199 }
200 }
201
202 [XmlIgnore]
203 internal bool IsPreprocessed
204 {
205 get
206 {
207 return _isPreprocessed;
208 }
209 set
210 {
212 }
213 }
214
215 [XmlIgnore]
216 internal bool IsRedefined
217 {
218 get
219 {
220 return _isRedefined;
221 }
222 set
223 {
225 }
226 }
227
228 [XmlIgnore]
230 {
231 get
232 {
233 if (_attributes == null)
234 {
236 }
237 return _attributes;
238 }
239 }
240
241 [XmlIgnore]
243 {
244 get
245 {
246 if (_attributeGroups == null)
247 {
249 }
250 return _attributeGroups;
251 }
252 }
253
254 [XmlIgnore]
256 {
257 get
258 {
259 if (_types == null)
260 {
262 }
263 return _types;
264 }
265 }
266
267 [XmlIgnore]
268 public XmlSchemaObjectTable Elements
269 {
270 get
271 {
272 if (_elements == null)
273 {
275 }
276 return _elements;
277 }
278 }
279
280 [XmlAttribute("id", DataType = "ID")]
281 public string? Id
282 {
283 get
284 {
285 return _id;
286 }
287 set
288 {
289 _id = value;
290 }
291 }
292
293 [XmlAnyAttribute]
295 {
296 get
297 {
298 return _moreAttributes;
299 }
300 set
301 {
303 }
304 }
305
306 [XmlIgnore]
308
309 [XmlIgnore]
311
312 [XmlIgnore]
314
315 [XmlIgnore]
316 internal Uri? BaseUri
317 {
318 get
319 {
320 return _baseUri;
321 }
322 set
323 {
324 _baseUri = value;
325 }
326 }
327
328 [XmlIgnore]
329 internal int SchemaId
330 {
331 get
332 {
333 if (_schemaId == -1)
334 {
336 }
337 return _schemaId;
338 }
339 }
340
341 [XmlIgnore]
342 internal bool IsChameleon
343 {
344 get
345 {
346 return _isChameleon;
347 }
348 set
349 {
351 }
352 }
353
354 [XmlIgnore]
355 internal Hashtable Ids => _ids;
356
357 [XmlIgnore]
359 {
360 get
361 {
362 if (_document == null)
363 {
364 _document = new XmlDocument();
365 }
366 return _document;
367 }
368 }
369
370 [XmlIgnore]
371 internal int ErrorCount
372 {
373 get
374 {
375 return _errorCount;
376 }
377 set
378 {
380 }
381 }
382
383 [XmlIgnore]
384 internal override string? IdAttribute
385 {
386 get
387 {
388 return Id;
389 }
390 set
391 {
392 Id = value;
393 }
394 }
395
397 {
398 get
399 {
400 if (_nameTable == null)
401 {
402 _nameTable = new NameTable();
403 }
404 return _nameTable;
405 }
406 }
407
409 {
410 get
411 {
412 if (_importedSchemas == null)
413 {
415 }
416 return _importedSchemas;
417 }
418 }
419
421 {
422 get
423 {
424 if (_importedNamespaces == null)
425 {
427 }
428 return _importedNamespaces;
429 }
430 }
431
432 public static XmlSchema? Read(TextReader reader, ValidationEventHandler? validationEventHandler)
433 {
434 return Read(new XmlTextReader(reader), validationEventHandler);
435 }
436
437 public static XmlSchema? Read(Stream stream, ValidationEventHandler? validationEventHandler)
438 {
439 return Read(new XmlTextReader(stream), validationEventHandler);
440 }
441
442 public static XmlSchema? Read(XmlReader reader, ValidationEventHandler? validationEventHandler)
443 {
445 Parser parser = new Parser(SchemaType.XSD, nameTable, new SchemaNames(nameTable), validationEventHandler);
446 try
447 {
448 parser.Parse(reader, null);
449 }
450 catch (XmlSchemaException ex)
451 {
452 if (validationEventHandler != null)
453 {
454 validationEventHandler(null, new ValidationEventArgs(ex));
455 return null;
456 }
457 throw;
458 }
459 return parser.XmlSchema;
460 }
461
462 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
463 public void Write(Stream stream)
464 {
465 Write(stream, null);
466 }
467
468 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
469 public void Write(Stream stream, XmlNamespaceManager? namespaceManager)
470 {
473 Write(xmlTextWriter, namespaceManager);
474 }
475
476 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
478 {
479 Write(writer, null);
480 }
481
482 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
483 public void Write(TextWriter writer, XmlNamespaceManager? namespaceManager)
484 {
487 Write(xmlTextWriter, namespaceManager);
488 }
489
490 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
491 public void Write(XmlWriter writer)
492 {
493 Write(writer, null);
494 }
495
497 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
498 public void Write(XmlWriter writer, XmlNamespaceManager? namespaceManager)
499 {
502 if (namespaceManager != null)
503 {
505 bool flag = false;
506 if (base.Namespaces != null)
507 {
508 flag = base.Namespaces.TryLookupPrefix("xs", out var _) || base.Namespaces.TryLookupNamespace("http://www.w3.org/2001/XMLSchema", out var _);
509 }
510 if (!flag && namespaceManager.LookupPrefix("http://www.w3.org/2001/XMLSchema") == null && namespaceManager.LookupNamespace("xs") == null)
511 {
512 xmlSerializerNamespaces.Add("xs", "http://www.w3.org/2001/XMLSchema");
513 }
514 foreach (string item in namespaceManager)
515 {
516 if (item != "xml" && item != "xmlns")
517 {
518 xmlSerializerNamespaces.Add(item, namespaceManager.LookupNamespace(item));
519 }
520 }
521 }
522 else if (base.Namespaces != null && base.Namespaces.Count > 0)
523 {
524 if (!base.Namespaces.TryLookupPrefix("xs", out var _) && !base.Namespaces.TryLookupNamespace("http://www.w3.org/2001/XMLSchema", out var _))
525 {
526 base.Namespaces.Add("xs", "http://www.w3.org/2001/XMLSchema");
527 }
528 xmlSerializerNamespaces = base.Namespaces;
529 }
530 else
531 {
533 xmlSerializerNamespaces.Add("xs", "http://www.w3.org/2001/XMLSchema");
534 if (_targetNs != null && _targetNs.Length != 0)
535 {
537 }
538 }
540 }
541
542 [Obsolete("XmlSchema.Compile has been deprecated. Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation instead.")]
543 public void Compile(ValidationEventHandler? validationEventHandler)
544 {
545 SchemaInfo schemaInfo = new SchemaInfo();
547 CompileSchema(null, null, schemaInfo, null, validationEventHandler, NameTable, CompileContentModel: false);
548 }
549
550 [Obsolete("XmlSchema.Compile has been deprecated. Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation instead.")]
551 public void Compile(ValidationEventHandler? validationEventHandler, XmlResolver? resolver)
552 {
553 SchemaInfo schemaInfo = new SchemaInfo();
555 CompileSchema(null, resolver, schemaInfo, null, validationEventHandler, NameTable, CompileContentModel: false);
556 }
557
558 internal bool CompileSchema(XmlSchemaCollection xsc, XmlResolver resolver, SchemaInfo schemaInfo, string ns, ValidationEventHandler validationEventHandler, XmlNameTable nameTable, bool CompileContentModel)
559 {
560 lock (this)
561 {
564 if (!schemaCollectionPreprocessor.Execute(this, ns, loadExternals: true, xsc))
565 {
566 return false;
567 }
569 _isCompiled = schemaCollectionCompiler.Execute(this, schemaInfo, CompileContentModel);
571 return _isCompiled;
572 }
573 }
574
581
598
623
624 internal void SetIsCompiled(bool isCompiled)
625 {
627 }
628
633
634 internal override void AddAnnotation(XmlSchemaAnnotation annotation)
635 {
636 _items.Add(annotation);
637 }
638
640 {
641 if (extList.Contains(schema))
642 {
643 return;
644 }
645 extList.Add(schema);
646 for (int i = 0; i < schema.Includes.Count; i++)
647 {
649 if (xmlSchemaExternal.Schema != null)
650 {
652 }
653 }
654 }
655}
static int Increment(ref int location)
void Write(Stream stream)
Definition XmlSchema.cs:463
XmlSchemaForm _attributeFormDefault
Definition XmlSchema.cs:17
XmlSchemaObjectCollection _includes
Definition XmlSchema.cs:29
XmlAttribute[] _moreAttributes
Definition XmlSchema.cs:35
readonly XmlSchemaObjectTable _identityConstraints
Definition XmlSchema.cs:59
XmlSchemaObjectCollection _items
Definition XmlSchema.cs:31
readonly Hashtable _ids
Definition XmlSchema.cs:73
XmlSchemaObjectTable SchemaTypes
Definition XmlSchema.cs:256
XmlSchemaObjectTable _types
Definition XmlSchema.cs:53
XmlSchemaObjectTable AttributeGroups
Definition XmlSchema.cs:243
static ? XmlSchema Read(Stream stream, ValidationEventHandler? validationEventHandler)
Definition XmlSchema.cs:437
XmlSchemaDerivationMethod _finalDefault
Definition XmlSchema.cs:23
XmlSchemaDerivationMethod FinalDefault
Definition XmlSchema.cs:110
XmlSchemaDerivationMethod BlockDefault
Definition XmlSchema.cs:96
XmlSchemaObjectCollection Includes
Definition XmlSchema.cs:164
void Compile(ValidationEventHandler? validationEventHandler)
Definition XmlSchema.cs:543
void Write(TextWriter writer, XmlNamespaceManager? namespaceManager)
Definition XmlSchema.cs:483
static ? XmlSchema Read(XmlReader reader, ValidationEventHandler? validationEventHandler)
Definition XmlSchema.cs:442
XmlSchemaObjectTable Groups
Definition XmlSchema.cs:307
XmlSchemaObjectTable _elements
Definition XmlSchema.cs:51
void CompileSchemaInSet(XmlNameTable nameTable, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings)
Definition XmlSchema.cs:575
void SetIsCompiled(bool isCompiled)
Definition XmlSchema.cs:624
XmlSchemaObjectTable Notations
Definition XmlSchema.cs:310
XmlSchemaDerivationMethod _blockDefault
Definition XmlSchema.cs:21
XmlSchemaObjectTable _attributes
Definition XmlSchema.cs:47
override void SetUnhandledAttributes(XmlAttribute[] moreAttributes)
Definition XmlSchema.cs:629
XmlSchemaObjectTable _attributeGroups
Definition XmlSchema.cs:49
XmlSchemaForm ElementFormDefault
Definition XmlSchema.cs:124
override? string IdAttribute
Definition XmlSchema.cs:385
readonly XmlSchemaObjectTable _notations
Definition XmlSchema.cs:57
XmlSchemaForm AttributeFormDefault
Definition XmlSchema.cs:82
void Write(XmlWriter writer, XmlNamespaceManager? namespaceManager)
Definition XmlSchema.cs:498
static ? XmlSchema Read(TextReader reader, ValidationEventHandler? validationEventHandler)
Definition XmlSchema.cs:432
void Write(TextWriter writer)
Definition XmlSchema.cs:477
readonly XmlSchemaObjectTable _groups
Definition XmlSchema.cs:55
XmlSchemaObjectTable IdentityConstraints
Definition XmlSchema.cs:313
void Write(XmlWriter writer)
Definition XmlSchema.cs:491
override void AddAnnotation(XmlSchemaAnnotation annotation)
Definition XmlSchema.cs:634
void Compile(ValidationEventHandler? validationEventHandler, XmlResolver? resolver)
Definition XmlSchema.cs:551
void Write(Stream stream, XmlNamespaceManager? namespaceManager)
Definition XmlSchema.cs:469
XmlAttribute?[] UnhandledAttributes
Definition XmlSchema.cs:295
XmlSchemaObjectTable Attributes
Definition XmlSchema.cs:230
bool CompileSchema(XmlSchemaCollection xsc, XmlResolver resolver, SchemaInfo schemaInfo, string ns, ValidationEventHandler validationEventHandler, XmlNameTable nameTable, bool CompileContentModel)
Definition XmlSchema.cs:558
XmlSchemaForm _elementFormDefault
Definition XmlSchema.cs:19
void GetExternalSchemasList(IList extList, XmlSchema schema)
Definition XmlSchema.cs:639
const string InstanceNamespace
Definition XmlSchema.cs:15
virtual ? string LookupNamespace(string prefix)
virtual ? string LookupPrefix(string uri)
XmlNameTable NameTable
Definition XmlReader.cs:116