当前位置: 首页>>代码示例>>C#>>正文


C# XmlReaderSettings类代码示例

本文整理汇总了C#中XmlReaderSettings的典型用法代码示例。如果您正苦于以下问题:C# XmlReaderSettings类的具体用法?C# XmlReaderSettings怎么用?C# XmlReaderSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlReaderSettings类属于命名空间,在下文中一共展示了XmlReaderSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: v3

        public int v3()
        {
            string xml = "<a/>";
            XmlReaderSettings rs = new XmlReaderSettings();
            try
            {
                rs.MaxCharactersFromEntities = -1;
                return TEST_FAIL;
            }
            catch (ArgumentOutOfRangeException) { }
            try
            {
                rs.MaxCharactersInDocument = -1;
                return TEST_FAIL;
            }
            catch (ArgumentOutOfRangeException) { }
            CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error");
            CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error");

            rs.MaxCharactersFromEntities = 10;
            rs.MaxCharactersInDocument = 10;
            using (XmlReader r = ReaderHelper.Create(new StringReader(xml), rs))
            {
                while (r.Read()) ;
                CError.Compare((int)r.Settings.MaxCharactersFromEntities, 10, "Error");
                CError.Compare((int)r.Settings.MaxCharactersInDocument, 10, "Error");
            }
            return TEST_PASS;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:29,代码来源:MaxSettings.cs

示例2: LoadXml

				public LoadXml(Stream schemaStream)
				{		
					m_settings = new XmlReaderSettings();
					m_settings.Schemas.Add(XmlSchema.Read(schemaStream, DoValidationEvent));
					m_settings.ValidationEventHandler += DoValidationEvent;
					m_settings.ValidationType = ValidationType.Schema;
				}
开发者ID:dbremner,项目名称:smokey,代码行数:7,代码来源:MethodCanBeMadeStaticRule.cs

示例3: Create

        public override XmlReader Create(MyDict<string, object> options)
        {
            XmlReaderSettings settings = (XmlReaderSettings)options[ReaderFactory.HT_READERSETTINGS];
            if (settings == null)
                settings = new XmlReaderSettings();

            Stream stream = (Stream)options[ReaderFactory.HT_STREAM];
            string filename = (string)options[ReaderFactory.HT_FILENAME];
            object readerType = options[ReaderFactory.HT_READERTYPE];
            string fragment = (string)options[ReaderFactory.HT_FRAGMENT];

            if (stream != null)
            {
                XmlReader reader = ReaderHelper.Create(stream, settings, filename);
                return reader;
            }

            if (fragment != null)
            {
                StringReader tr = new StringReader(fragment);
                XmlReader reader = ReaderHelper.Create(tr, settings, "someUri");

                return reader;
            }

            if (filename != null)
            {
                XmlReader reader = ReaderHelper.Create(filename, settings);
                return reader;
            }

            throw new CTestFailedException("No Reader Created");
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:33,代码来源:ReaderSettings.cs

示例4: v1

        public int v1()
        {
            string strFile = NameTable_TestFiles.GetTestFileName(EREADER_TYPE.GENERIC);

            // create custom nametable
            MyXmlNameTable nt = new MyXmlNameTable();
            string play = nt.Add("PLAY");
            string foo = nt.Add("http://www.foo.com");

            XmlReaderSettings xrs = new XmlReaderSettings();
            xrs.NameTable = nt;
            xrs.DtdProcessing = DtdProcessing.Ignore;
            XmlReader r = XmlReader.Create(FilePathUtil.getStream(strFile), xrs);
            while (r.Read()) ;

            // verify name table
            object play2 = nt.Get("PLAY");
            object foo2 = nt.Get("http://www.foo.com");

            CError.Compare((object)play == play2, "play");
            CError.Compare((object)foo == foo2, "foo");

            CError.Compare(nt.Get("NONEMPTY0") != null, "NONEMPTY0");
            CError.WriteLine("Final count={0} atoms", nt.Count);

            return TEST_PASS;
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:27,代码来源:InheritNameTable.cs

示例5: v1

 public int v1()
 {
     XmlReaderSettings rs = new XmlReaderSettings();
     CError.Compare(rs.CheckCharacters, true, "CheckCharacters not true");
     CError.Compare(rs.ConformanceLevel, ConformanceLevel.Document, "Conformance Level not document by default");
     return TEST_PASS;
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:7,代码来源:ConformanceSettings.cs

示例6: Create

        public override XmlReader Create(MyDict<string, object> options)
        {
            string tcDesc = (string)options[ReaderFactory.HT_CURDESC];
            string tcVar = (string)options[ReaderFactory.HT_CURVAR];

            CError.Compare(tcDesc == "wrappedreader", "Invalid testcase");

            XmlReaderSettings rs = (XmlReaderSettings)options[ReaderFactory.HT_READERSETTINGS];
            Stream stream = (Stream)options[ReaderFactory.HT_STREAM];
            string filename = (string)options[ReaderFactory.HT_FILENAME];
            object readerType = options[ReaderFactory.HT_READERTYPE];
            object vt = options[ReaderFactory.HT_VALIDATIONTYPE];
            string fragment = (string)options[ReaderFactory.HT_FRAGMENT];
            StringReader sr = (StringReader)options[ReaderFactory.HT_STRINGREADER];

            if (rs == null)
                rs = new XmlReaderSettings();

            rs.DtdProcessing = DtdProcessing.Ignore;
            if (sr != null)
            {
                CError.WriteLine("WrappedReader String");

                XmlReader r = ReaderHelper.Create(sr, rs, string.Empty);
                XmlReader wr = ReaderHelper.Create(r, rs);
                return wr;
            }

            if (stream != null)
            {
                CError.WriteLine("WrappedReader Stream");

                XmlReader r = ReaderHelper.Create(stream, rs, filename);
                XmlReader wr = ReaderHelper.Create(r, rs);
                return wr;
            }

            if (fragment != null)
            {
                CError.WriteLine("WrappedReader Fragment");
                rs.ConformanceLevel = ConformanceLevel.Fragment;
                StringReader tr = new StringReader(fragment);

                XmlReader r = ReaderHelper.Create(tr, rs, (string)null);
                XmlReader wr = ReaderHelper.Create(r, rs);
                return wr;
            }

            if (filename != null)
            {
                CError.WriteLine("WrappedReader Filename");

                Stream fs = FilePathUtil.getStream(filename);
                XmlReader r = ReaderHelper.Create(fs, rs, filename);
                XmlReader wr = ReaderHelper.Create(r, rs);
                return wr;
            }
            throw new CTestFailedException("WrappedReader not created");
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:59,代码来源:InheritedCases.cs

示例7: v2

 public int v2()
 {
     XmlReaderSettings rs = new XmlReaderSettings();
     rs.MaxCharactersFromEntities = 1;
     rs.MaxCharactersInDocument = 1;
     CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error");
     CError.Compare((int)rs.MaxCharactersInDocument, 1, "Error");
     return TEST_PASS;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:MaxSettings.cs

示例8: XmlCustomReader

 public XmlCustomReader(TextReader textReader, XmlReaderSettings settings, string baseUri)
 {
     XmlReader w = ReaderHelper.Create(textReader, settings, baseUri);
     XmlReaderSettings wsettings = new XmlReaderSettings();
     wsettings.CheckCharacters = true;
     wsettings.DtdProcessing = DtdProcessing.Ignore;
     wsettings.ConformanceLevel = ConformanceLevel.Auto;
     _wrappedreader = ReaderHelper.Create(w, wsettings);
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:9,代码来源:CReader.cs

示例9: GetContent

        protected SyndicationFeed GetContent()
        {
            XmlReaderSettings xrs = new XmlReaderSettings();

            XmlReader reader = XmlReader.Create(_contentURI, xrs);

            SyndicationFeed feed = SyndicationFeed.Load(reader);

            return feed;
        }
开发者ID:CarlosLCervantes,项目名称:D3Services,代码行数:10,代码来源:RSSReader.cs

示例10: CompareReader

        public bool CompareReader(string strExpected)
        {
            XmlReaderSettings readerSettings = new XmlReaderSettings();
            readerSettings.CheckCharacters = false;
            readerSettings.CloseInput = true;
            readerSettings.ConformanceLevel = ConformanceLevel.Auto;

            StringReader sr = new StringReader(strExpected);
            XmlReader xrExpected = XmlReader.Create(sr, readerSettings);
            return this.XmlWriterTestModule.WriterFactory.CompareReader(xrExpected);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:XmlWriterTestCaseBase.cs

示例11: v1

        public int v1()
        {
            XmlReaderSettings rs = new XmlReaderSettings();
            CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error");
            CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error");

            using (XmlReader r = ReaderHelper.Create(new StringReader("<foo/>")))
            {
                CError.Compare(r.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error");
                CError.Compare(r.Settings.MaxCharactersInDocument, _defaultCharsDoc, "Error");
            }
            return TEST_PASS;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:MaxSettings.cs

示例12: CreateFragmentReader

        public static XmlReader CreateFragmentReader(string fragment)
        {
            var settings = new XmlReaderSettings
            {
                DtdProcessing = DtdProcessing.Ignore,
                CheckCharacters = false,
                ConformanceLevel = ConformanceLevel.Fragment
            };

            var stream = new StringReader(fragment);

            return XmlReader.Create(stream, settings);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:Utils.cs

示例13: LoadDocumentFromFile

        public void LoadDocumentFromFile()
        {
            TextReader textReader = File.OpenText(@"example.xml");
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreWhitespace = true;
            settings.DtdProcessing = DtdProcessing.Ignore;
            XmlDocument doc = new XmlDocument();

            using (StringReader sr = new StringReader(textReader.ReadToEnd()))
            using (XmlReader reader = XmlReader.Create(sr, settings))
            {
                doc.Load(reader);
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:LoadTests.cs

示例14: DisposeDisposesInputStream

        public static void DisposeDisposesInputStream()
        {
            bool[] asyncValues = { false, true };
            bool[] closeInputValues = { false, true };

            foreach (var async in asyncValues)
                foreach (var closeInput in closeInputValues)
                {
                    using (Stream s = CreateXmlStream())
                    {
                        XmlReaderSettings settings = new XmlReaderSettings();
                        settings.Async = async;
                        settings.CloseInput = closeInput;

                        XmlReader reader = XmlReader.Create(s, settings);
                        if (async)
                        {
                            // Underlying Stream is not being disposed when using async and not reading anything
                            // async is delaying initialization until you start to read (allegedly to not block on IO when creating reader)
                            reader.Read();
                        }
                        reader.Dispose();
                        if (closeInput)
                        {
                            Assert.Throws<ObjectDisposedException>(() =>
                            {
                                s.Position = 0;
                                s.ReadByte();
                            });
                        }
                        else
                        {
                            s.Position = 0;
                            s.ReadByte();
                            // does not throw ObjectDisposedException
                        }

                        // should not throw
                        reader.Dispose();
                    }
                }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:42,代码来源:DisposeTests.cs

示例15: pi00

        public int pi00()
        {
            XmlReaderSettings settings = new XmlReaderSettings();
            if (settings.IgnoreProcessingInstructions == true)
            {
                CError.WriteLineIgnore("RS default value = true");
                return TEST_FAIL;
            }
            if (settings.IgnoreComments == true)
            {
                CError.WriteLineIgnore("RS Comm default value = true");
                return TEST_FAIL;
            }
            if (settings.IgnoreWhitespace == true)
            {
                CError.WriteLineIgnore("RS WS default value = true");
                return TEST_FAIL;
            }

            return TEST_PASS;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:21,代码来源:FilterSettings.cs


注:本文中的XmlReaderSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。