Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlValidatingReaderImpl.cs
Go to the documentation of this file.
3using System.IO;
4using System.Text;
7
8namespace System.Xml;
9
11{
23
25 {
27
28 private ValidationEventHandler _eventHandler;
29
31
33 {
34 _reader = reader;
35 }
36
48
49 internal void AddHandler(ValidationEventHandler handler)
50 {
52 }
53
54 internal void RemoveHandler(ValidationEventHandler handler)
55 {
57 }
58 }
59
60 private readonly XmlReader _coreReader;
61
63
65
67
69
71
72 private readonly bool _processIdentityConstraints;
73
75
77
79
81
83
85
101
103
104 public override string Name => _coreReader.Name;
105
106 public override string LocalName => _coreReader.LocalName;
107
108 public override string NamespaceURI => _coreReader.NamespaceURI;
109
110 public override string Prefix => _coreReader.Prefix;
111
112 public override bool HasValue => _coreReader.HasValue;
113
114 public override string Value => _coreReader.Value;
115
116 public override int Depth => _coreReader.Depth;
117
118 public override string BaseURI => _coreReader.BaseURI;
119
121
122 public override bool IsDefault => _coreReader.IsDefault;
123
124 public override char QuoteChar => _coreReader.QuoteChar;
125
127
128 public override string XmlLang => _coreReader.XmlLang;
129
130 public override ReadState ReadState
131 {
132 get
133 {
135 {
136 return _coreReader.ReadState;
137 }
138 return ReadState.Initial;
139 }
140 }
141
142 public override bool EOF => _coreReader.EOF;
143
145
146 internal Encoding Encoding => _coreReaderImpl.Encoding;
147
149
150 public override bool CanReadBinaryContent => true;
151
152 public override bool CanResolveEntity => true;
153
155 {
156 set
157 {
159 }
160 }
161
162 public int LineNumber => ((IXmlLineInfo)_coreReader).LineNumber;
163
164 public int LinePosition => ((IXmlLineInfo)_coreReader).LinePosition;
165
166 internal object SchemaType
167 {
168 get
169 {
170 if (_validationType != 0)
171 {
172 if (_coreReaderImpl.InternalSchemaType is XmlSchemaType xmlSchemaType && xmlSchemaType.QualifiedName.Namespace == "http://www.w3.org/2001/XMLSchema")
173 {
174 return xmlSchemaType.Datatype;
175 }
177 }
178 return null;
179 }
180 }
181
182 internal XmlReader Reader => _coreReader;
183
185
187 {
188 get
189 {
190 return _validationType;
191 }
192 set
193 {
194 if (ReadState != 0)
195 {
197 }
200 }
201 }
202
204
206 {
207 get
208 {
209 return _coreReaderImpl.EntityHandling;
210 }
211 set
212 {
214 }
215 }
216
226
227 internal bool Namespaces
228 {
229 get
230 {
231 return _coreReaderImpl.Namespaces;
232 }
233 set
234 {
236 }
237 }
238
240 {
241 get
242 {
243 return _validator;
244 }
245 set
246 {
248 }
249 }
250
252
254
255 internal object SchemaTypeObject
256 {
257 set
258 {
260 }
261 }
262
263 internal object TypedValueObject
264 {
265 get
266 {
268 }
269 set
270 {
272 }
273 }
274
276
277 internal event ValidationEventHandler ValidationEventHandler
278 {
279 add
280 {
282 }
283 remove
284 {
286 }
287 }
288
318
321 {
322 if (_coreReader.BaseURI.Length > 0)
323 {
325 }
326 if (context != null)
327 {
328 _parsingFunction = ParsingFunction.ParseDtdFromContext;
329 _parserContext = context;
330 }
331 }
332
335 {
336 if (_coreReader.BaseURI.Length > 0)
337 {
339 }
340 if (context != null)
341 {
342 _parsingFunction = ParsingFunction.ParseDtdFromContext;
343 _parserContext = context;
344 }
345 }
346
379
380 public override string GetAttribute(string name)
381 {
382 return _coreReader.GetAttribute(name);
383 }
384
385 public override string GetAttribute(string localName, string namespaceURI)
386 {
387 return _coreReader.GetAttribute(localName, namespaceURI);
388 }
389
390 public override string GetAttribute(int i)
391 {
392 return _coreReader.GetAttribute(i);
393 }
394
395 public override bool MoveToAttribute(string name)
396 {
397 if (!_coreReader.MoveToAttribute(name))
398 {
399 return false;
400 }
402 return true;
403 }
404
405 public override bool MoveToAttribute(string localName, string namespaceURI)
406 {
408 {
409 return false;
410 }
412 return true;
413 }
414
415 public override void MoveToAttribute(int i)
416 {
419 }
420
421 public override bool MoveToFirstAttribute()
422 {
424 {
425 return false;
426 }
428 return true;
429 }
430
431 public override bool MoveToNextAttribute()
432 {
434 {
435 return false;
436 }
438 return true;
439 }
440
441 public override bool MoveToElement()
442 {
444 {
445 return false;
446 }
448 return true;
449 }
450
451 public override bool Read()
452 {
453 switch (_parsingFunction)
454 {
455 case ParsingFunction.Read:
456 if (_coreReader.Read())
457 {
459 return true;
460 }
462 return false;
463 case ParsingFunction.ParseDtdFromContext:
466 goto case ParsingFunction.Read;
467 case ParsingFunction.ReaderClosed:
468 case ParsingFunction.Error:
469 return false;
470 case ParsingFunction.Init:
472 if (_coreReader.ReadState == ReadState.Interactive)
473 {
475 return true;
476 }
477 goto case ParsingFunction.Read;
478 case ParsingFunction.ResolveEntityInternally:
481 goto case ParsingFunction.Read;
482 case ParsingFunction.InReadBinaryContent:
485 goto case ParsingFunction.Read;
486 default:
487 return false;
488 }
489 }
490
491 public override void Close()
492 {
494 _parsingFunction = ParsingFunction.ReaderClosed;
495 }
496
497 public override string LookupNamespace(string prefix)
498 {
500 }
501
502 public override bool ReadAttributeValue()
503 {
504 if (_parsingFunction == ParsingFunction.InReadBinaryContent)
505 {
508 }
510 {
511 return false;
512 }
514 return true;
515 }
516
517 public override int ReadContentAsBase64(byte[] buffer, int index, int count)
518 {
519 if (ReadState != ReadState.Interactive)
520 {
521 return 0;
522 }
523 if (_parsingFunction != ParsingFunction.InReadBinaryContent)
524 {
526 }
529 _parsingFunction = ParsingFunction.InReadBinaryContent;
530 return result;
531 }
532
533 public override int ReadContentAsBinHex(byte[] buffer, int index, int count)
534 {
535 if (ReadState != ReadState.Interactive)
536 {
537 return 0;
538 }
539 if (_parsingFunction != ParsingFunction.InReadBinaryContent)
540 {
542 }
545 _parsingFunction = ParsingFunction.InReadBinaryContent;
546 return result;
547 }
548
549 public override int ReadElementContentAsBase64(byte[] buffer, int index, int count)
550 {
551 if (ReadState != ReadState.Interactive)
552 {
553 return 0;
554 }
555 if (_parsingFunction != ParsingFunction.InReadBinaryContent)
556 {
558 }
561 _parsingFunction = ParsingFunction.InReadBinaryContent;
562 return result;
563 }
564
565 public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
566 {
567 if (ReadState != ReadState.Interactive)
568 {
569 return 0;
570 }
571 if (_parsingFunction != ParsingFunction.InReadBinaryContent)
572 {
574 }
577 _parsingFunction = ParsingFunction.InReadBinaryContent;
578 return result;
579 }
580
581 public override void ResolveEntity()
582 {
583 if (_parsingFunction == ParsingFunction.ResolveEntityInternally)
584 {
586 }
588 }
589
591 {
592 if (_outerReader.NodeType == XmlNodeType.EntityReference && _parsingFunction != ParsingFunction.ResolveEntityInternally && !_outerReader.Read())
593 {
595 }
596 }
597
598 public override string ReadString()
599 {
601 return base.ReadString();
602 }
603
604 public bool HasLineInfo()
605 {
606 return true;
607 }
608
613
615 {
616 return LookupNamespace(prefix);
617 }
618
623
628
629 internal string LookupPrefix(string namespaceName)
630 {
632 }
633
634 public object ReadTypedValue()
635 {
637 {
638 return null;
639 }
640 switch (_outerReader.NodeType)
641 {
642 case XmlNodeType.Attribute:
644 case XmlNodeType.Element:
645 {
646 if (SchemaType == null)
647 {
648 return null;
649 }
651 if (xmlSchemaDatatype != null)
652 {
654 {
655 XmlNodeType nodeType;
656 do
657 {
658 if (!_outerReader.Read())
659 {
661 }
662 nodeType = _outerReader.NodeType;
663 }
664 while (nodeType == XmlNodeType.CDATA || nodeType == XmlNodeType.Text || nodeType == XmlNodeType.Whitespace || nodeType == XmlNodeType.SignificantWhitespace || nodeType == XmlNodeType.Comment || nodeType == XmlNodeType.ProcessingInstruction);
665 if (_outerReader.NodeType != XmlNodeType.EndElement)
666 {
668 }
669 }
671 }
672 return null;
673 }
674 case XmlNodeType.EndElement:
675 return null;
676 default:
678 {
679 return null;
680 }
681 return Value;
682 }
683 }
684
696
697 private void ValidateDtd()
698 {
700 if (dtdInfo != null)
701 {
702 switch (_validationType)
703 {
704 default:
705 return;
706 case ValidationType.Auto:
708 break;
709 case ValidationType.None:
710 case ValidationType.DTD:
711 break;
712 }
714 }
715 }
716
718 {
719 int depth = _coreReader.Depth;
721 while (_outerReader.Read() && _coreReader.Depth > depth)
722 {
723 }
724 }
725
726 [MemberNotNull("_validator")]
738
740 {
742 if (resolver == null && !_coreReaderImpl.IsResolverSet)
743 {
744 if (s_tempResolver == null)
745 {
747 }
748 return s_tempResolver;
749 }
750 return resolver;
751 }
752
754 {
755 switch (_coreReader.NodeType)
756 {
757 case XmlNodeType.Whitespace:
759 {
761 }
762 break;
763 case XmlNodeType.DocumentType:
764 ValidateDtd();
765 return;
766 case XmlNodeType.EntityReference:
767 _parsingFunction = ParsingFunction.ResolveEntityInternally;
768 break;
769 }
773 }
774
779
787
788 public override Task<string> GetValueAsync()
789 {
790 return _coreReader.GetValueAsync();
791 }
792
793 public override async Task<bool> ReadAsync()
794 {
795 switch (_parsingFunction)
796 {
797 case ParsingFunction.Read:
798 if (await _coreReader.ReadAsync().ConfigureAwait(continueOnCapturedContext: false))
799 {
801 return true;
802 }
804 return false;
805 case ParsingFunction.ParseDtdFromContext:
808 goto case ParsingFunction.Read;
809 case ParsingFunction.ReaderClosed:
810 case ParsingFunction.Error:
811 return false;
812 case ParsingFunction.Init:
814 if (_coreReader.ReadState == ReadState.Interactive)
815 {
817 return true;
818 }
819 goto case ParsingFunction.Read;
820 case ParsingFunction.ResolveEntityInternally:
823 goto case ParsingFunction.Read;
824 case ParsingFunction.InReadBinaryContent:
827 goto case ParsingFunction.Read;
828 default:
829 return false;
830 }
831 }
832
833 public override async Task<int> ReadContentAsBase64Async(byte[] buffer, int index, int count)
834 {
835 if (ReadState != ReadState.Interactive)
836 {
837 return 0;
838 }
839 if (_parsingFunction != ParsingFunction.InReadBinaryContent)
840 {
842 }
845 _parsingFunction = ParsingFunction.InReadBinaryContent;
846 return result;
847 }
848
849 public override async Task<int> ReadContentAsBinHexAsync(byte[] buffer, int index, int count)
850 {
851 if (ReadState != ReadState.Interactive)
852 {
853 return 0;
854 }
855 if (_parsingFunction != ParsingFunction.InReadBinaryContent)
856 {
858 }
861 _parsingFunction = ParsingFunction.InReadBinaryContent;
862 return result;
863 }
864
866 {
867 if (ReadState != ReadState.Interactive)
868 {
869 return 0;
870 }
871 if (_parsingFunction != ParsingFunction.InReadBinaryContent)
872 {
874 }
877 _parsingFunction = ParsingFunction.InReadBinaryContent;
878 return result;
879 }
880
882 {
883 if (ReadState != ReadState.Interactive)
884 {
885 return 0;
886 }
887 if (_parsingFunction != ParsingFunction.InReadBinaryContent)
888 {
890 }
893 _parsingFunction = ParsingFunction.InReadBinaryContent;
894 return result;
895 }
896
908
917}
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static ? Delegate Combine(Delegate? a, Delegate? b)
Definition Delegate.cs:379
static string Arg_ExpectingXmlTextReader
Definition SR.cs:1820
static string Xml_InvalidNodeType
Definition SR.cs:88
static string Xml_InvalidOperation
Definition SR.cs:18
Definition SR.cs:7
static IDtdParser Create()
Definition DtdParser.cs:261
async Task< int > ReadElementContentAsBase64Async(byte[] buffer, int index, int count)
static ReadContentAsBinaryHelper CreateOrReset(ReadContentAsBinaryHelper helper, XmlReader reader)
async Task< int > ReadContentAsBase64Async(byte[] buffer, int index, int count)
int ReadContentAsBase64(byte[] buffer, int index, int count)
int ReadContentAsBinHex(byte[] buffer, int index, int count)
int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
int ReadElementContentAsBase64(byte[] buffer, int index, int count)
async Task< int > ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count)
async Task< int > ReadContentAsBinHexAsync(byte[] buffer, int index, int count)
static BaseValidator CreateInstance(ValidationType valType, XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, IValidationEventHandling eventHandling, bool processIdentityConstraints)
static void CheckDefaultValue(SchemaAttDef attdef, SchemaInfo sinfo, IValidationEventHandling eventHandling, string baseUriStr)
virtual XmlSpace XmlSpace
Definition XmlReader.cs:96
string? GetAttribute(string name)
virtual bool HasValue
Definition XmlReader.cs:82
bool MoveToAttribute(string name)
virtual ? XmlReaderSettings Settings
Definition XmlReader.cs:60
virtual bool IsDefault
Definition XmlReader.cs:92
virtual char QuoteChar
Definition XmlReader.cs:94
virtual ? IDtdInfo DtdInfo
Definition XmlReader.cs:145
virtual Task< bool > ReadAsync()
virtual string XmlLang
Definition XmlReader.cs:98
virtual void Close()
Definition XmlReader.cs:528
XmlNodeType NodeType
Definition XmlReader.cs:62
XmlNameTable NameTable
Definition XmlReader.cs:116
virtual Task< string > GetValueAsync()
virtual string Name
Definition XmlReader.cs:65
virtual Uri ResolveUri(Uri? baseUri, string? relativeUri)
void ChangeCurrentNodeType(XmlNodeType newNodeType)
void SetDtdInfo(IDtdInfo newDtdInfo)
override XmlNamespaceManager NamespaceManager
bool AddDefaultAttributeNonDtd(SchemaAttDef attrDef)
override string LookupNamespace(string prefix)
override async Task< int > ReadElementContentAsBase64Async(byte[] buffer, int index, int count)
ReadContentAsBinaryHelper _readBinaryHelper
void ValidateDefaultAttributeOnUse(IDtdDefaultAttributeInfo defaultAttribute, XmlTextReaderImpl coreReader)
string LookupPrefix(string namespaceName)
XmlValidatingReaderImpl(Stream xmlFragment, XmlNodeType fragType, XmlParserContext context)
override async Task< int > ReadContentAsBinHexAsync(byte[] buffer, int index, int count)
bool AddDefaultAttribute(SchemaAttDef attdef)
XmlValidatingReaderImpl(string xmlFragment, XmlNodeType fragType, XmlParserContext context)
override string GetAttribute(string localName, string namespaceURI)
override int ReadElementContentAsBase64(byte[] buffer, int index, int count)
readonly XmlTextReaderImpl _coreReaderImpl
readonly ValidationEventHandling _eventHandling
override int ReadContentAsBase64(byte[] buffer, int index, int count)
override async Task< int > ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count)
override bool MoveToAttribute(string localName, string namespaceURI)
readonly XmlSchemaCollection _schemaCollection
override XmlNamespaceManager NamespaceManager
override async Task< int > ReadContentAsBase64Async(byte[] buffer, int index, int count)
override async Task< bool > ReadAsync()
override int ReadContentAsBinHex(byte[] buffer, int index, int count)
readonly IXmlNamespaceResolver _coreReaderNSResolver
void SetupValidation(ValidationType valType)
override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
IDictionary< string, string > IXmlNamespaceResolver. GetNamespacesInScope(XmlNamespaceScope scope)
string IXmlNamespaceResolver. LookupPrefix(string namespaceName)
IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
XmlValidatingReaderImpl(XmlReader reader, ValidationEventHandler settingsEventHandler, bool processIdentityConstraints)
override string LookupNamespace(string prefix)
override string GetAttribute(string name)
void SendEvent(Exception exception, XmlSeverityType severity)
IDictionary< string, string > GetNamespacesInScope(XmlNamespaceScope scope)
string? LookupPrefix(string namespaceName)
string? LookupNamespace(string prefix)
UriKind
Definition UriKind.cs:4