Beispiel #1
0
        // 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(SR.Arg_ExpectingXmlTextReader, nameof(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);
        }
        // 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(Res.GetString(Res.Arg_ExpectingXmlTextReader), "reader");
            }
            coreReaderImpl.XmlValidatingReaderCompatibilityMode = true;
            coreReaderNSResolver            = reader as IXmlNamespaceResolver;
            this.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);
        }
        // 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( Res.GetString( Res.Arg_ExpectingXmlTextReader ), "reader" );
            }
            coreReaderImpl.XmlValidatingReaderCompatibilityMode = true;
            coreReaderNSResolver = reader as IXmlNamespaceResolver;
            this.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 );
        }