Load() private method

Loads the configuration file.
private Load ( ) : void
return void
        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 = config = source.Configs["new section"];
            Assert.AreEqual("Rover", config.Get("dog"));
            Assert.AreEqual("Muffy", config.Get("cat"));

            File.Delete(filePath);
        }
示例#2
0
        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 = config = source.Configs["new section"];
            Assert.AreEqual("Rover", config.Get("dog"));
            Assert.AreEqual("Muffy", config.Get("cat"));

            File.Delete(filePath);
        }