コード例 #1
0
 /// <summary>
 /// Returns the section from the specified resource with the given section name. Use <paramref name="defaultConfigurationSectionHandlerType"/>
 /// in case no section handler is specified.
 /// </summary>
 public static object GetSection(IResource resource, string configSectionName, Type defaultConfigurationSectionHandlerType)
 {
     using (Stream istm = resource.InputStream)
     {
         ConfigXmlDocument doc = new ConfigXmlDocument();
         doc.Load(istm);
         return(GetSectionFromXmlDocument(doc, configSectionName, defaultConfigurationSectionHandlerType));
     }
 }
コード例 #2
0
        public void LoadTextReaderStoresTextPosition()
        {
            ConfigXmlDocument xmlDoc = new ConfigXmlDocument();
            Stream            istm   = TestResourceLoader.GetStream(this, "_SampleConfig.xml");

            xmlDoc.Load("MYXML", new StreamReader(istm));
            ITextPosition pos = ((ITextPosition)xmlDoc.SelectSingleNode("//property"));

            Assert.AreEqual("MYXML", pos.Filename);
            Assert.AreEqual(5, pos.LineNumber);
            Assert.AreEqual(14, pos.LinePosition);
        }
コード例 #3
0
        public void CanConfigFilenameAndLine()
        {
            ConfigXmlDocument xmlDoc = new ConfigXmlDocument();
            Stream            istm   = TestResourceLoader.GetStream(this, "_SampleConfig.xml");

            xmlDoc.Load("MYXML", new StreamReader(istm));
            XmlNode node = xmlDoc.SelectSingleNode("//property");

            Assert.AreEqual("MYXML", ConfigurationUtils.GetFileName(node));
            Assert.AreEqual(5, ConfigurationUtils.GetLineNumber(node));
            //Assert.AreEqual(14, pos.LinePosition); <- IConfigErrorInfo/IConfigXmlNode do not support LinePosition
        }
コード例 #4
0
        public void LoadXmlStoresTextPosition()
        {
            ConfigXmlDocument xmlDoc  = new ConfigXmlDocument();
            string            xmlText = TestResourceLoader.GetText(this, "_SampleConfig.xml");

            xmlDoc.LoadXml("MYXML", xmlText);
            ITextPosition pos = ((ITextPosition)xmlDoc.SelectSingleNode("//property"));

            Assert.AreEqual("MYXML", pos.Filename);
            Assert.AreEqual(5, pos.LineNumber);
            Assert.AreEqual(14, pos.LinePosition);
        }