本文整理汇总了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"));
}