12 [global::__DynamicallyInvokable]
16 private bool useAsync;
22 private int lineNumberOffset;
24 private int linePositionOffset;
28 private bool checkCharacters;
30 private long maxCharactersInDocument;
32 private long maxCharactersFromEntities;
34 private bool ignoreWhitespace;
36 private bool ignorePIs;
38 private bool ignoreComments;
50 private bool closeInput;
52 private bool isReadOnly;
54 private static bool? s_enableLegacyXmlSettings;
59 [global::__DynamicallyInvokable]
62 [global::__DynamicallyInvokable]
67 [global::__DynamicallyInvokable]
70 CheckReadOnly(
"Async");
77 [global::__DynamicallyInvokable]
80 [global::__DynamicallyInvokable]
85 [global::__DynamicallyInvokable]
88 CheckReadOnly(
"NameTable");
93 internal bool IsXmlResolverSet
105 CheckReadOnly(
"XmlResolver");
107 IsXmlResolverSet =
true;
113 [global::__DynamicallyInvokable]
116 [global::__DynamicallyInvokable]
119 return lineNumberOffset;
121 [global::__DynamicallyInvokable]
124 CheckReadOnly(
"LineNumberOffset");
125 lineNumberOffset = value;
131 [global::__DynamicallyInvokable]
134 [global::__DynamicallyInvokable]
137 return linePositionOffset;
139 [global::__DynamicallyInvokable]
142 CheckReadOnly(
"LinePositionOffset");
143 linePositionOffset = value;
149 [global::__DynamicallyInvokable]
152 [global::__DynamicallyInvokable]
155 return conformanceLevel;
157 [global::__DynamicallyInvokable]
160 CheckReadOnly(
"ConformanceLevel");
161 if ((uint)value > 2u)
165 conformanceLevel = value;
172 [global::__DynamicallyInvokable]
175 [global::__DynamicallyInvokable]
178 return checkCharacters;
180 [global::__DynamicallyInvokable]
183 CheckReadOnly(
"CheckCharacters");
184 checkCharacters = value;
190 [global::__DynamicallyInvokable]
193 [global::__DynamicallyInvokable]
196 return maxCharactersInDocument;
198 [global::__DynamicallyInvokable]
201 CheckReadOnly(
"MaxCharactersInDocument");
206 maxCharactersInDocument = value;
212 [global::__DynamicallyInvokable]
215 [global::__DynamicallyInvokable]
218 return maxCharactersFromEntities;
220 [global::__DynamicallyInvokable]
223 CheckReadOnly(
"MaxCharactersFromEntities");
228 maxCharactersFromEntities = value;
235 [global::__DynamicallyInvokable]
238 [global::__DynamicallyInvokable]
241 return ignoreWhitespace;
243 [global::__DynamicallyInvokable]
246 CheckReadOnly(
"IgnoreWhitespace");
247 ignoreWhitespace = value;
254 [global::__DynamicallyInvokable]
257 [global::__DynamicallyInvokable]
262 [global::__DynamicallyInvokable]
265 CheckReadOnly(
"IgnoreProcessingInstructions");
273 [global::__DynamicallyInvokable]
276 [global::__DynamicallyInvokable]
279 return ignoreComments;
281 [global::__DynamicallyInvokable]
284 CheckReadOnly(
"IgnoreComments");
285 ignoreComments = value;
292 [Obsolete(
"Use XmlReaderSettings.DtdProcessing property instead.")]
301 CheckReadOnly(
"ProhibitDtd");
308 [global::__DynamicallyInvokable]
311 [global::__DynamicallyInvokable]
314 return dtdProcessing;
316 [global::__DynamicallyInvokable]
319 CheckReadOnly(
"DtdProcessing");
320 if ((uint)value > 2u)
324 dtdProcessing = value;
331 [global::__DynamicallyInvokable]
334 [global::__DynamicallyInvokable]
339 [global::__DynamicallyInvokable]
342 CheckReadOnly(
"CloseInput");
353 return validationType;
357 CheckReadOnly(
"ValidationType");
358 if ((uint)value > 4u)
362 validationType = value;
372 return validationFlags;
376 CheckReadOnly(
"ValidationFlags");
377 if ((uint)value > 31u)
381 validationFlags = value;
399 CheckReadOnly(
"Schemas");
404 internal bool ReadOnly
421 CheckReadOnly(
"ValidationEventHandler");
426 CheckReadOnly(
"ValidationEventHandler");
432 [global::__DynamicallyInvokable]
440 [Obsolete(
"This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.",
true)]
444 Initialize(resolver);
462 [global::__DynamicallyInvokable]
465 CheckReadOnly(
"Reset");
471 [global::__DynamicallyInvokable]
475 xmlReaderSettings.ReadOnly =
false;
476 return xmlReaderSettings;
481 return valEventHandler;
484 internal XmlReader CreateReader(
string inputUri, XmlParserContext inputContext)
486 if (inputUri ==
null)
490 if (inputUri.Length == 0)
492 throw new ArgumentException(Res.GetString(
"XmlConvert_BadUri"),
"inputUri");
495 if (xmlResolver ==
null)
497 xmlResolver = CreateDefaultResolver();
499 XmlReader xmlReader =
new XmlTextReaderImpl(inputUri,
this, inputContext, xmlResolver);
502 xmlReader = AddValidation(xmlReader);
506 xmlReader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(xmlReader);
511 internal XmlReader CreateReader(
Stream input, Uri baseUri,
string baseUriString, XmlParserContext inputContext)
515 throw new ArgumentNullException(
"input");
517 if (baseUriString ==
null)
519 baseUriString = ((!(baseUri ==
null)) ? baseUri.ToString() :
string.Empty);
521 XmlReader xmlReader =
new XmlTextReaderImpl(input,
null, 0,
this, baseUri, baseUriString, inputContext, closeInput);
524 xmlReader = AddValidation(xmlReader);
528 xmlReader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(xmlReader);
533 internal XmlReader CreateReader(
TextReader input,
string baseUriString, XmlParserContext inputContext)
537 throw new ArgumentNullException(
"input");
539 if (baseUriString ==
null)
541 baseUriString =
string.Empty;
543 XmlReader xmlReader =
new XmlTextReaderImpl(input,
this, baseUriString, inputContext);
546 xmlReader = AddValidation(xmlReader);
550 xmlReader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(xmlReader);
555 internal XmlReader CreateReader(XmlReader reader)
559 throw new ArgumentNullException(
"reader");
561 return AddValidationAndConformanceWrapper(reader);
564 private void CheckReadOnly(
string propertyName)
568 throw new XmlException(
"Xml_ReadOnlyProperty", GetType().Name +
"." + propertyName);
572 private void Initialize()
580 if (!EnableLegacyXmlSettings())
582 xmlResolver = resolver;
583 maxCharactersFromEntities = 10000000
L;
587 xmlResolver = ((resolver ==
null) ? CreateDefaultResolver() : resolver);
588 maxCharactersFromEntities = 0
L;
590 lineNumberOffset = 0;
591 linePositionOffset = 0;
592 checkCharacters =
true;
594 ignoreWhitespace =
false;
596 ignoreComments =
false;
599 maxCharactersInDocument = 0
L;
606 IsXmlResolverSet =
false;
611 return new XmlUrlResolver();
614 internal XmlReader AddValidation(XmlReader reader)
618 XmlResolver xmlResolver = GetXmlResolver_CheckConfig();
619 if (xmlResolver ==
null && !IsXmlResolverSet && !EnableLegacyXmlSettings())
621 xmlResolver =
new XmlUrlResolver();
623 reader =
new XsdValidatingReader(reader, xmlResolver,
this);
627 reader = CreateDtdValidatingReader(reader);
632 private XmlReader AddValidationAndConformanceWrapper(XmlReader reader)
636 reader = CreateDtdValidatingReader(reader);
638 reader = AddConformanceWrapper(reader);
641 reader =
new XsdValidatingReader(reader, GetXmlResolver_CheckConfig(),
this);
646 private XmlValidatingReaderImpl CreateDtdValidatingReader(XmlReader baseReader)
651 internal XmlReader AddConformanceWrapper(XmlReader baseReader)
657 bool ignorePis =
false;
660 if (settings ==
null)
662 if (conformanceLevel != 0 && conformanceLevel != XmlReader.GetV1ConformanceLevel(baseReader))
664 throw new InvalidOperationException(Res.GetString(
"Xml_IncompatibleConformanceLevel", conformanceLevel.ToString()));
666 XmlTextReader xmlTextReader = baseReader as XmlTextReader;
667 if (xmlTextReader ==
null)
669 XmlValidatingReader xmlValidatingReader = baseReader as XmlValidatingReader;
670 if (xmlValidatingReader !=
null)
672 xmlTextReader = (XmlTextReader)xmlValidatingReader.Reader;
675 if (ignoreWhitespace)
678 if (xmlTextReader !=
null)
680 whitespaceHandling = xmlTextReader.WhitespaceHandling;
699 if (xmlTextReader !=
null)
701 dtdProcessing2 = xmlTextReader.DtdProcessing;
705 dtdProcessing = this.dtdProcessing;
711 if (conformanceLevel != settings.ConformanceLevel && conformanceLevel != 0)
713 throw new InvalidOperationException(Res.GetString(
"Xml_IncompatibleConformanceLevel", conformanceLevel.ToString()));
715 if (checkCharacters && !settings.CheckCharacters)
720 if (ignoreWhitespace && !settings.IgnoreWhitespace)
725 if (ignoreComments && !settings.IgnoreComments)
730 if (ignorePIs && !settings.IgnoreProcessingInstructions)
737 dtdProcessing = this.dtdProcessing;
743 IXmlNamespaceResolver xmlNamespaceResolver = baseReader as IXmlNamespaceResolver;
744 if (xmlNamespaceResolver !=
null)
746 return new XmlCharCheckingReaderWithNS(baseReader, xmlNamespaceResolver, flag, flag2, flag3, ignorePis, dtdProcessing);
748 return new XmlCharCheckingReader(baseReader, flag, flag2, flag3, ignorePis, dtdProcessing);
753 internal static bool EnableLegacyXmlSettings()
755 if (s_enableLegacyXmlSettings.HasValue)
757 return s_enableLegacyXmlSettings.Value;
759 if (!BinaryCompatibility.TargetsAtLeast_Desktop_V4_5_2)
761 s_enableLegacyXmlSettings =
true;
762 return s_enableLegacyXmlSettings.Value;
765 if (!ReadSettingsFromRegistry(Registry.LocalMachine, ref value))
767 ReadSettingsFromRegistry(Registry.CurrentUser, ref value);
769 s_enableLegacyXmlSettings = value;
770 return s_enableLegacyXmlSettings.Value;
773 [SecuritySafeCritical]
775 private static bool ReadSettingsFromRegistry(RegistryKey hive, ref
bool value)
779 using (
RegistryKey registryKey = hive.OpenSubKey(
"SOFTWARE\\Microsoft\\.NETFramework\\XML", writable:
false))
781 if (registryKey !=
null && registryKey.GetValueKind(
"EnableLegacyXmlSettings") == RegistryValueKind.DWord)
783 value = ((int)registryKey.GetValue(
"EnableLegacyXmlSettings") == 1);
bool Async
Gets or sets whether asynchronous T:System.Xml.XmlReader methods can be used on a particular T:System...
bool IgnoreProcessingInstructions
Gets or sets a value indicating whether to ignore processing instructions.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
ValidationEventHandler ValidationEventHandler
Occurs when the reader encounters validation errors.
XmlReaderSettings(XmlResolver resolver)
Initializes a new instance of the T:System.Xml.XmlReaderSettings class.
Controls the ability to access registry variables. This class cannot be inherited.
EditorBrowsableState
Specifies the browsable state of a property or method from within an editor.
XmlReaderSettings Clone()
Creates a copy of the T:System.Xml.XmlReaderSettings instance.
XmlReaderSettings()
Initializes a new instance of the T:System.Xml.XmlReaderSettings class.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
Resolves external XML resources named by a Uniform Resource Identifier (URI).
int LineNumberOffset
Gets or sets line number offset of the T:System.Xml.XmlReader object.
ValidationType
Specifies the type of validation to perform.
int LinePositionOffset
Gets or sets line position offset of the T:System.Xml.XmlReader object.
long MaxCharactersInDocument
Gets or sets a value indicating the maximum allowable number of characters in an XML document....
Specifies a set of features to support on the T:System.Xml.XmlReader object created by the Overload:S...
static Delegate Remove(Delegate source, Delegate value)
Removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
static Delegate Combine(Delegate a, Delegate b)
Concatenates the invocation lists of two delegates.
DtdProcessing DtdProcessing
Gets or sets a value that determines the processing of DTDs.
bool CheckCharacters
Gets or sets a value indicating whether to do character checking.
XmlSchemaSet Schemas
Gets or sets the T:System.Xml.Schema.XmlSchemaSet to use when performing schema validation.
WhitespaceHandling
Specifies how white space is handled.
ConformanceLevel ConformanceLevel
Gets or sets the level of conformance which the T:System.Xml.XmlReader will comply.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Implements a single-threaded T:System.Xml.XmlNameTable.
Represents a collection that can contain many different types of permissions.
ConformanceLevel
Specifies the amount of input or output checking that T:System.Xml.XmlReader and T:System....
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Table of atomized string objects.
XmlSchemaValidationFlags ValidationFlags
Gets or sets a value indicating the schema validation settings. This setting applies to T:System....
bool IgnoreComments
Gets or sets a value indicating whether to ignore comments.
Represents a reader that can read a sequential series of characters.
XmlResolver XmlResolver
Sets the T:System.Xml.XmlResolver used to access external documents.
ValidationType ValidationType
Gets or sets a value indicating whether the T:System.Xml.XmlReader will perform validation or type as...
DtdProcessing
Specifies the options for processing DTDs. The T:System.Xml.DtdProcessing enumeration is used by the ...
bool? ProhibitDtd
Gets or sets a value indicating whether to prohibit document type definition (DTD) processing....
bool CloseInput
Gets or sets a value indicating whether the underlying stream or T:System.IO.TextReader should be clo...
bool IgnoreWhitespace
Gets or sets a value indicating whether to ignore insignificant white space.
XmlSchemaValidationFlags
Specifies schema validation options used by the T:System.Xml.Schema.XmlSchemaValidator and T:System....
long MaxCharactersFromEntities
Gets or sets a value indicating the maximum allowable number of characters in a document that result ...
void Reset()
Resets the members of the settings class to their default values.
Represents an XML reader section.
Contains a cache of XML Schema definition language (XSD) schemas.
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....