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


C# XmlConfigSource.ReplaceKeyValues方法代码示例

本文整理汇总了C#中Nini.Config.XmlConfigSource.ReplaceKeyValues方法的典型用法代码示例。如果您正苦于以下问题:C# XmlConfigSource.ReplaceKeyValues方法的具体用法?C# XmlConfigSource.ReplaceKeyValues怎么用?C# XmlConfigSource.ReplaceKeyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nini.Config.XmlConfigSource的用法示例。


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

示例1: ReplaceText

        public void ReplaceText()
        {
            StringWriter textWriter = new StringWriter ();
            XmlTextWriter xmlWriter = NiniWriter (textWriter);
            WriteSection (xmlWriter, "Test");
            WriteKey (xmlWriter, "author", "Brent");
            WriteKey (xmlWriter, "domain", "${protocol}://nini.sf.net/");
            WriteKey (xmlWriter, "apache", "Apache implements ${protocol}");
            WriteKey (xmlWriter, "developer", "author of Nini: ${author} !");
            WriteKey (xmlWriter, "love", "We love the ${protocol} protocol");
            WriteKey (xmlWriter, "combination", "${author} likes ${protocol}");
            WriteKey (xmlWriter, "fact", "fact: ${apache}");
            WriteKey (xmlWriter, "protocol", "http");
            xmlWriter.WriteEndDocument ();

            StringReader reader = new StringReader (textWriter.ToString ());
            XmlTextReader xmlReader = new XmlTextReader (reader);
            XmlConfigSource source = new XmlConfigSource (xmlReader);
            source.ReplaceKeyValues ();

            IConfig config = source.Configs["Test"];
            Assert.AreEqual ("http", config.Get ("protocol"));
            Assert.AreEqual ("fact: Apache implements http", config.Get ("fact"));
            Assert.AreEqual ("http://nini.sf.net/", config.Get ("domain"));
            Assert.AreEqual ("Apache implements http", config.Get ("apache"));
            Assert.AreEqual ("We love the http protocol", config.Get ("love"));
            Assert.AreEqual ("author of Nini: Brent !", config.Get ("developer"));
            Assert.AreEqual ("Brent likes http", config.Get ("combination"));
        }
开发者ID:rwhitworth,项目名称:nini,代码行数:29,代码来源:XmlConfigSourceTests.cs


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