Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlReaderSettings.cs
Go to the documentation of this file.
1using System.IO;
3
4namespace System.Xml;
5
6public sealed class XmlReaderSettings
7{
9
11 {
12 ReadOnly = true
13 };
14
15 private bool _useAsync;
16
18
20
21 private int _lineNumberOffset;
22
24
26
27 private bool _checkCharacters;
28
30
32
33 private bool _ignoreWhitespace;
34
35 private bool _ignorePIs;
36
37 private bool _ignoreComments;
38
40
42
44
46
47 private ValidationEventHandler _valEventHandler;
48
49 private bool _closeInput;
50
51 private bool _isReadOnly;
52
53 private AddValidationFunc _addValidationFunc;
54
55 public bool Async
56 {
57 get
58 {
59 return _useAsync;
60 }
61 set
62 {
63 CheckReadOnly("Async");
65 }
66 }
67
69 {
70 get
71 {
72 return _nameTable;
73 }
74 set
75 {
76 CheckReadOnly("NameTable");
78 }
79 }
80
81 internal bool IsXmlResolverSet { get; set; }
82
84 {
85 set
86 {
87 CheckReadOnly("XmlResolver");
89 IsXmlResolverSet = true;
90 }
91 }
92
94 {
95 get
96 {
97 return _lineNumberOffset;
98 }
99 set
100 {
101 CheckReadOnly("LineNumberOffset");
103 }
104 }
105
107 {
108 get
109 {
110 return _linePositionOffset;
111 }
112 set
113 {
114 CheckReadOnly("LinePositionOffset");
116 }
117 }
118
120 {
121 get
122 {
123 return _conformanceLevel;
124 }
125 set
126 {
127 CheckReadOnly("ConformanceLevel");
128 if ((uint)value > 2u)
129 {
130 throw new ArgumentOutOfRangeException("value");
131 }
133 }
134 }
135
136 public bool CheckCharacters
137 {
138 get
139 {
140 return _checkCharacters;
141 }
142 set
143 {
144 CheckReadOnly("CheckCharacters");
146 }
147 }
148
150 {
151 get
152 {
154 }
155 set
156 {
157 CheckReadOnly("MaxCharactersInDocument");
158 if (value < 0)
159 {
160 throw new ArgumentOutOfRangeException("value");
161 }
163 }
164 }
165
167 {
168 get
169 {
171 }
172 set
173 {
174 CheckReadOnly("MaxCharactersFromEntities");
175 if (value < 0)
176 {
177 throw new ArgumentOutOfRangeException("value");
178 }
180 }
181 }
182
184 {
185 get
186 {
187 return _ignoreWhitespace;
188 }
189 set
190 {
191 CheckReadOnly("IgnoreWhitespace");
193 }
194 }
195
197 {
198 get
199 {
200 return _ignorePIs;
201 }
202 set
203 {
204 CheckReadOnly("IgnoreProcessingInstructions");
206 }
207 }
208
209 public bool IgnoreComments
210 {
211 get
212 {
213 return _ignoreComments;
214 }
215 set
216 {
217 CheckReadOnly("IgnoreComments");
219 }
220 }
221
222 [Obsolete("XmlReaderSettings.ProhibitDtd has been deprecated. Use DtdProcessing instead.")]
223 public bool ProhibitDtd
224 {
225 get
226 {
227 return _dtdProcessing == DtdProcessing.Prohibit;
228 }
229 set
230 {
231 CheckReadOnly("ProhibitDtd");
232 _dtdProcessing = ((!value) ? DtdProcessing.Parse : DtdProcessing.Prohibit);
233 }
234 }
235
237 {
238 get
239 {
240 return _dtdProcessing;
241 }
242 set
243 {
244 CheckReadOnly("DtdProcessing");
245 if ((uint)value > 2u)
246 {
247 throw new ArgumentOutOfRangeException("value");
248 }
250 }
251 }
252
253 public bool CloseInput
254 {
255 get
256 {
257 return _closeInput;
258 }
259 set
260 {
261 CheckReadOnly("CloseInput");
263 }
264 }
265
267 {
268 get
269 {
270 return _validationType;
271 }
272 set
273 {
274 CheckReadOnly("ValidationType");
276 if ((uint)value > 4u)
277 {
278 throw new ArgumentOutOfRangeException("value");
279 }
281 }
282 }
283
285 {
286 get
287 {
288 return _validationFlags;
289 }
290 set
291 {
292 CheckReadOnly("ValidationFlags");
293 if ((uint)value > 31u)
294 {
295 throw new ArgumentOutOfRangeException("value");
296 }
298 }
299 }
300
302 {
303 get
304 {
305 if (_schemas == null)
306 {
307 _schemas = new XmlSchemaSet();
308 }
309 return _schemas;
310 }
311 set
312 {
313 CheckReadOnly("Schemas");
314 _schemas = value;
315 }
316 }
317
318 internal bool ReadOnly
319 {
320 set
321 {
323 }
324 }
325
326 public event ValidationEventHandler ValidationEventHandler
327 {
328 add
329 {
330 CheckReadOnly("ValidationEventHandler");
332 }
333 remove
334 {
335 CheckReadOnly("ValidationEventHandler");
337 }
338 }
339
341 {
342 Initialize();
343 }
344
346 {
347 return _xmlResolver;
348 }
349
351 {
353 {
354 return null;
355 }
356 return _xmlResolver;
357 }
358
359 public void Reset()
360 {
361 CheckReadOnly("Reset");
362 Initialize();
363 }
364
371
372 internal ValidationEventHandler GetEventHandler()
373 {
374 return _valEventHandler;
375 }
376
377 internal XmlReader CreateReader(string inputUri, XmlParserContext inputContext)
378 {
379 if (inputUri == null)
380 {
381 throw new ArgumentNullException("inputUri");
382 }
383 if (inputUri.Length == 0)
384 {
385 throw new ArgumentException(System.SR.XmlConvert_BadUri, "inputUri");
386 }
388 XmlReader xmlReader = new XmlTextReaderImpl(inputUri, this, inputContext, uriResolver);
389 if (ValidationType != 0)
390 {
392 }
393 if (_useAsync)
394 {
396 }
397 return xmlReader;
398 }
399
400 internal XmlReader CreateReader(Stream input, Uri baseUri, string baseUriString, XmlParserContext inputContext)
401 {
402 if (input == null)
403 {
404 throw new ArgumentNullException("input");
405 }
406 if (baseUriString == null)
407 {
408 baseUriString = ((!(baseUri == null)) ? baseUri.ToString() : string.Empty);
409 }
410 XmlReader xmlReader = new XmlTextReaderImpl(input, null, 0, this, baseUri, baseUriString, inputContext, _closeInput);
411 if (ValidationType != 0)
412 {
414 }
415 if (_useAsync)
416 {
418 }
419 return xmlReader;
420 }
421
423 {
424 if (input == null)
425 {
426 throw new ArgumentNullException("input");
427 }
428 if (baseUriString == null)
429 {
430 baseUriString = string.Empty;
431 }
432 XmlReader xmlReader = new XmlTextReaderImpl(input, this, baseUriString, inputContext);
433 if (ValidationType != 0)
434 {
436 }
437 if (_useAsync)
438 {
440 }
441 return xmlReader;
442 }
443
445 {
446 if (reader == null)
447 {
448 throw new ArgumentNullException("reader");
449 }
451 }
452
453 private void CheckReadOnly(string propertyName)
454 {
455 if (_isReadOnly)
456 {
457 throw new XmlException(System.SR.Xml_ReadOnlyProperty, GetType().Name + "." + propertyName);
458 }
459 }
460
461 private void Initialize()
462 {
463 Initialize(null);
464 }
465
467 {
468 _nameTable = null;
473 _checkCharacters = true;
475 _ignoreWhitespace = false;
476 _ignorePIs = false;
477 _ignoreComments = false;
478 _dtdProcessing = DtdProcessing.Prohibit;
479 _closeInput = false;
481 _schemas = null;
483 _validationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints;
484 _validationFlags |= XmlSchemaValidationFlags.AllowXmlAttributes;
485 _useAsync = false;
486 _isReadOnly = false;
487 IsXmlResolverSet = false;
488 }
489
491 {
493 if (_validationType == ValidationType.Schema)
494 {
496 if (xmlResolver == null && !IsXmlResolverSet)
497 {
499 }
500 }
502 }
503
513
515 {
517 {
519 {
520 reader = AddConformanceWrapper(reader);
521 }
522 }
523 else
524 {
526 }
527 return reader;
528 }
529
531 {
533 {
534 reader = CreateDtdValidatingReader(reader);
535 }
537 {
538 reader = AddConformanceWrapper(reader);
539 }
540 if (_validationType == ValidationType.Schema)
541 {
542 reader = new XsdValidatingReader(reader, GetXmlResolver_CheckConfig(), this);
543 }
544 return reader;
545 }
546
551
553 {
554 XmlReaderSettings settings = baseReader.Settings;
555 bool checkCharacters = false;
556 bool ignoreWhitespace = false;
557 bool ignoreComments = false;
558 bool ignorePis = false;
560 bool flag = false;
561 if (settings == null)
562 {
564 {
566 }
569 {
571 }
573 {
575 if (xmlTextReader != null)
576 {
577 whitespaceHandling = xmlTextReader.WhitespaceHandling;
578 }
580 {
581 ignoreWhitespace = true;
582 flag = true;
583 }
584 }
585 if (_ignoreComments)
586 {
587 ignoreComments = true;
588 flag = true;
589 }
590 if (_ignorePIs)
591 {
592 ignorePis = true;
593 flag = true;
594 }
596 if (xmlTextReader != null)
597 {
598 dtdProcessing2 = xmlTextReader.DtdProcessing;
599 }
600 if ((_dtdProcessing == DtdProcessing.Prohibit && dtdProcessing2 != 0) || (_dtdProcessing == DtdProcessing.Ignore && dtdProcessing2 == DtdProcessing.Parse))
601 {
603 flag = true;
604 }
605 }
606 else
607 {
609 {
611 }
612 if (_checkCharacters && !settings.CheckCharacters)
613 {
614 checkCharacters = true;
615 flag = true;
616 }
617 if (_ignoreWhitespace && !settings.IgnoreWhitespace)
618 {
619 ignoreWhitespace = true;
620 flag = true;
621 }
622 if (_ignoreComments && !settings.IgnoreComments)
623 {
624 ignoreComments = true;
625 flag = true;
626 }
628 {
629 ignorePis = true;
630 flag = true;
631 }
632 if ((_dtdProcessing == DtdProcessing.Prohibit && settings.DtdProcessing != 0) || (_dtdProcessing == DtdProcessing.Ignore && settings.DtdProcessing == DtdProcessing.Parse))
633 {
635 flag = true;
636 }
637 }
638 if (flag)
639 {
640 if (baseReader is IXmlNamespaceResolver readerAsNSResolver)
641 {
643 }
645 }
646 return baseReader;
647 }
648}
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static ? Delegate Combine(Delegate? a, Delegate? b)
Definition Delegate.cs:379
static string Xml_ReadOnlyProperty
Definition SR.cs:156
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Xml_IncompatibleConformanceLevel
Definition SR.cs:202
static string XmlConvert_BadUri
Definition SR.cs:368
Definition SR.cs:7
override string ToString()
Definition Uri.cs:1119
static XmlAsyncCheckReader CreateAsyncCheckWrapper(XmlReader reader)
AddValidationFunc _addValidationFunc
XmlReader AddValidation(XmlReader reader)
XmlReader CreateReader(string inputUri, XmlParserContext inputContext)
XmlReader CreateReader(TextReader input, string baseUriString, XmlParserContext inputContext)
XmlReader AddValidationAndConformanceWrapper(XmlReader reader)
ValidationEventHandler ValidationEventHandler
XmlReader AddValidationInternal(XmlReader reader, XmlResolver resolver, bool addConformanceWrapper)
XmlSchemaValidationFlags _validationFlags
void CheckReadOnly(string propertyName)
XmlReader AddConformanceWrapper(XmlReader baseReader)
static readonly XmlReaderSettings s_defaultReaderSettings
XmlValidatingReaderImpl CreateDtdValidatingReader(XmlReader baseReader)
delegate XmlReader AddValidationFunc(XmlReader reader, XmlResolver resolver, bool addConformanceWrapper)
void Initialize(XmlResolver resolver)
XmlReader CreateReader(XmlReader reader)
ValidationEventHandler _valEventHandler
ValidationEventHandler GetEventHandler()
XmlReader AddValidationAndConformanceInternal(XmlReader reader, XmlResolver resolver, bool addConformanceWrapper)
XmlReader CreateReader(Stream input, Uri baseUri, string baseUriString, XmlParserContext inputContext)
XmlSchemaValidationFlags ValidationFlags
static ConformanceLevel GetV1ConformanceLevel(XmlReader reader)