本文整理汇总了C#中Nini.Config.IniConfigSource.Load方法的典型用法代码示例。如果您正苦于以下问题:C# IniConfigSource.Load方法的具体用法?C# IniConfigSource.Load怎么用?C# IniConfigSource.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nini.Config.IniConfigSource
的用法示例。
在下文中一共展示了IniConfigSource.Load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NiniDatabase
public NiniDatabase(string fileName)
{
if (string.IsNullOrWhiteSpace(fileName))
throw new ArgumentNullException("fileName");
if (!File.Exists(fileName))
{
//TODO Log error
FileStream fileStream = File.Create(fileName);
fileStream.Close();
}
IniConfigSource iniConfigSoruce = new Nini.Config.IniConfigSource();
iniConfigSoruce.AutoSave = true;
iniConfigSoruce.Load(fileName);
_storage = iniConfigSoruce;
}
示例2: LoadPath
public void LoadPath()
{
string filePath = "Test.ini";
StreamWriter writer = new StreamWriter (filePath);
writer.WriteLine ("; some comment");
writer.WriteLine ("[new section]");
writer.WriteLine (" dog = Rover");
writer.WriteLine (""); // empty line
writer.WriteLine ("; a comment");
writer.WriteLine (" cat = Muffy");
writer.Close ();
IniConfigSource source = new IniConfigSource (filePath);
IConfig config = source.Configs["new section"];
Assert.AreEqual ("Rover", config.Get ("dog"));
Assert.AreEqual ("Muffy", config.Get ("cat"));
config.Set ("dog", "Spots");
config.Set ("cat", "Misha");
config.Set ("DoesNotExist", "SomeValue");
source.Load (filePath);
config = source.Configs["new section"];
Assert.AreEqual ("Rover", config.Get ("dog"));
Assert.AreEqual ("Muffy", config.Get ("cat"));
File.Delete (filePath);
}