internal XmlReader CreateReader(TextReader input, string baseUriString, XmlParserContext inputContext) { if (input == null) { throw new ArgumentNullException("input"); } if (baseUriString == null) { baseUriString = string.Empty; } // create xml text reader XmlReader reader = new XmlTextReaderImpl(input, this, baseUriString, inputContext); // wrap with validating reader if (this.ValidationType != ValidationType.None) { reader = AddValidation(reader); } #if ASYNC if (useAsync) { reader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(reader); } #endif return(reader); }
// Initializes a new instance of XmlValidatingReaderImpl class with the specified arguments. // This constructor is used when creating XmlValidatingReaderImpl reader via "XmlReader.Create(..)" internal XmlValidatingReaderImpl(XmlReader reader, ValidationEventHandler settingsEventHandler, bool processIdentityConstraints) { XmlAsyncCheckReader asyncCheckReader = reader as XmlAsyncCheckReader; if (asyncCheckReader != null) { reader = asyncCheckReader.CoreReader; } _outerReader = this; _coreReader = reader; _coreReaderImpl = reader as XmlTextReaderImpl; if (_coreReaderImpl == null) { XmlTextReader tr = reader as XmlTextReader; if (tr != null) { _coreReaderImpl = tr.Impl; } } if (_coreReaderImpl == null) { throw new ArgumentException(ResXml.Arg_ExpectingXmlTextReader, "reader"); } _coreReaderImpl.XmlValidatingReaderCompatibilityMode = true; _coreReaderNSResolver = reader as IXmlNamespaceResolver; _processIdentityConstraints = processIdentityConstraints; #pragma warning disable 618 _schemaCollection = new XmlSchemaCollection(_coreReader.NameTable); #pragma warning restore 618 _schemaCollection.XmlResolver = GetResolver(); _eventHandling = new ValidationEventHandling(this); if (settingsEventHandler != null) { _eventHandling.AddHandler(settingsEventHandler); } _coreReaderImpl.ValidationEventHandling = _eventHandling; _coreReaderImpl.OnDefaultAttributeUse = new XmlTextReaderImpl.OnDefaultAttributeUseDelegate(ValidateDefaultAttributeOnUse); _validationType = ValidationType.DTD; SetupValidation(ValidationType.DTD); }
// [ResourceConsumption(ResourceScope.Machine)] // [ResourceExposure(ResourceScope.Machine)] internal XmlReader CreateReader(String inputUri, XmlParserContext inputContext) { if (inputUri == null) { throw new ArgumentNullException("inputUri"); } if (inputUri.Length == 0) { throw new ArgumentException(ResXml.XmlConvert_BadUri, "inputUri"); } // resolve and open the url XmlResolver tmpResolver = this.GetXmlResolver(); if (tmpResolver == null) { tmpResolver = CreateDefaultResolver(); } // create text XML reader XmlReader reader = new XmlTextReaderImpl(inputUri, this, inputContext, tmpResolver); // wrap with validating reader if (this.ValidationType != ValidationType.None) { reader = AddValidation(reader); } #if ASYNC if (useAsync) { reader = XmlAsyncCheckReader.CreateAsyncCheckWrapper(reader); } #endif return(reader); }