コード例 #1
0
        public QueryReaderSettings(XmlReader reader)
        {
#pragma warning disable 618
            XmlValidatingReader?valReader = reader as XmlValidatingReader;
#pragma warning restore 618
            if (valReader != null)
            {
                // Unwrap validation reader
                _validatingReader = true;
                reader            = valReader.Impl.Reader;
            }

            _xmlReaderSettings = reader.Settings;
            if (_xmlReaderSettings != null)
            {
                _xmlReaderSettings                    = _xmlReaderSettings.Clone();
                _xmlReaderSettings.NameTable          = reader.NameTable;
                _xmlReaderSettings.CloseInput         = true;
                _xmlReaderSettings.LineNumberOffset   = 0;
                _xmlReaderSettings.LinePositionOffset = 0;
                XmlTextReaderImpl?impl = reader as XmlTextReaderImpl;
                if (impl != null)
                {
                    _xmlReaderSettings.XmlResolver = impl.GetResolver();
                }
            }
            else
            {
                _xmlNameTable = reader.NameTable;
                XmlTextReader?xmlTextReader = reader as XmlTextReader;
                if (xmlTextReader != null)
                {
                    XmlTextReaderImpl impl = xmlTextReader.Impl;
                    _entityHandling     = impl.EntityHandling;
                    _namespaces         = impl.Namespaces;
                    _normalization      = impl.Normalization;
                    _prohibitDtd        = (impl.DtdProcessing == DtdProcessing.Prohibit);
                    _whitespaceHandling = impl.WhitespaceHandling;
                    _xmlResolver        = impl.GetResolver();
                }
                else
                {
                    _entityHandling     = EntityHandling.ExpandEntities;
                    _namespaces         = true;
                    _normalization      = true;
                    _prohibitDtd        = true;
                    _whitespaceHandling = WhitespaceHandling.All;
                    _xmlResolver        = null;
                }
            }
        }
コード例 #2
0
        public QueryReaderSettings(XmlReader reader)
        {
#pragma warning disable 618
            XmlValidatingReader valReader = reader as XmlValidatingReader;
#pragma warning restore 618
            if (valReader != null)
            {
                // Unwrap validation reader
                validatingReader = true;
                reader           = valReader.Impl.Reader;
            }
            xmlReaderSettings = reader.Settings;
            if (xmlReaderSettings != null)
            {
                xmlReaderSettings                    = xmlReaderSettings.Clone();
                xmlReaderSettings.NameTable          = reader.NameTable;
                xmlReaderSettings.CloseInput         = true;
                xmlReaderSettings.LineNumberOffset   = 0;
                xmlReaderSettings.LinePositionOffset = 0;
                XmlTextReaderImpl impl = reader as XmlTextReaderImpl;
                if (impl != null)
                {
                    xmlReaderSettings.XmlResolver = impl.GetResolver();
                }
            }
            else
            {
                xmlNameTable = reader.NameTable;
                XmlTextReader xmlTextReader = reader as XmlTextReader;
                if (xmlTextReader != null)
                {
                    XmlTextReaderImpl impl = xmlTextReader.Impl;
                    entityHandling     = impl.EntityHandling;
                    namespaces         = impl.Namespaces;
                    normalization      = impl.Normalization;
                    prohibitDtd        = impl.ProhibitDtd;
                    whitespaceHandling = impl.WhitespaceHandling;
                    xmlResolver        = impl.GetResolver();
                }
                else
                {
                    entityHandling     = EntityHandling.ExpandEntities;
                    namespaces         = true;
                    normalization      = true;
                    prohibitDtd        = true;
                    whitespaceHandling = WhitespaceHandling.All;
                    xmlResolver        = null;
                }
            }
        }
コード例 #3
0
        public QueryReaderSettings(XmlReader reader)
        {
            XmlValidatingReader reader2 = reader as XmlValidatingReader;

            if (reader2 != null)
            {
                this.validatingReader = true;
                reader = reader2.Impl.Reader;
            }
            this.xmlReaderSettings = reader.Settings;
            if (this.xmlReaderSettings != null)
            {
                this.xmlReaderSettings                    = this.xmlReaderSettings.Clone();
                this.xmlReaderSettings.NameTable          = reader.NameTable;
                this.xmlReaderSettings.CloseInput         = true;
                this.xmlReaderSettings.LineNumberOffset   = 0;
                this.xmlReaderSettings.LinePositionOffset = 0;
                XmlTextReaderImpl impl = reader as XmlTextReaderImpl;
                if (impl != null)
                {
                    this.xmlReaderSettings.XmlResolver = impl.GetResolver();
                }
            }
            else
            {
                this.xmlNameTable = reader.NameTable;
                XmlTextReader reader3 = reader as XmlTextReader;
                if (reader3 != null)
                {
                    XmlTextReaderImpl impl2 = reader3.Impl;
                    this.entityHandling     = impl2.EntityHandling;
                    this.namespaces         = impl2.Namespaces;
                    this.normalization      = impl2.Normalization;
                    this.prohibitDtd        = impl2.DtdProcessing == DtdProcessing.Prohibit;
                    this.whitespaceHandling = impl2.WhitespaceHandling;
                    this.xmlResolver        = impl2.GetResolver();
                }
                else
                {
                    this.entityHandling     = EntityHandling.ExpandEntities;
                    this.namespaces         = true;
                    this.normalization      = true;
                    this.prohibitDtd        = true;
                    this.whitespaceHandling = WhitespaceHandling.All;
                    this.xmlResolver        = null;
                }
            }
        }
コード例 #4
0
        // This is needed because we can't have the setter for XmlResolver public and with internal getter.
        private XmlResolver GetResolver()
        {
            XmlResolver tempResolver = _coreReaderImpl.GetResolver();

            if (tempResolver == null && !_coreReaderImpl.IsResolverSet &&
                !Microsoft.Xml.XmlReaderSettings.EnableLegacyXmlSettings())
            {
                // it is safe to return valid resolver as it'll be used in the schema validation
                if (s_tempResolver == null)
                {
                    s_tempResolver = new XmlUrlResolver();
                }
                return(s_tempResolver);
            }

            return(tempResolver);
        }