Exemplo n.º 1
0
        public Configuration ParseConfiguration(string configuration)
        {
            var parser = new IniDataParser();
            var data = parser.Parse(configuration);

            var config = new Configuration();

            foreach (var section in data.Sections)
            {
                var innerConfig = new Configuration();

                foreach (var key in section.Keys)
                {
                    innerConfig[RemoveWhiteSpace(key.KeyName)] = key.Value;
                }

                config[RemoveWhiteSpace(section.SectionName)] = innerConfig;
            }

            foreach (var key in data.Global)
            {
                config[RemoveWhiteSpace(key.KeyName)] = key.Value;
            }

            return config;
        }
Exemplo n.º 2
0
        public void parse_ini_string_with_custom_configuration()
        {
            var parser = new IniDataParser();
			
			IniParser.Model.Configuration.IIniParserConfiguration config = parser.Configuration;
			
			config.CommentString = "#";
			config.SectionStartChar = '<';
			config.SectionEndChar = '>';
			
            IniData data = parser.Parse(iniFileStrCustom);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Sections.Count, Is.EqualTo(2));
            var section1 = data.Sections.GetSectionData("section1");

            Assert.That(section1, Is.Not.Null);
            Assert.That(section1.SectionName, Is.EqualTo("section1"));
            Assert.That(section1.Comments, Is.Not.Empty);
            Assert.That(section1.Comments.Count, Is.EqualTo(1));

            Assert.That(section1.Keys, Is.Not.Null);
            Assert.That(section1.Keys.Count, Is.EqualTo(2));
            Assert.That(section1.Keys.GetKeyData("key1"), Is.Not.Null);
            Assert.That(section1.Keys["key1"], Is.EqualTo("value1"));
            Assert.That(section1.Keys.GetKeyData("key2"), Is.Not.Null);
            Assert.That(section1.Keys["key2"], Is.EqualTo("value5"));
        }
Exemplo n.º 3
0
        public void allow_duplicated_sections_in_section()
        {
            string data = 
@"[123_1]
key1=value1
key2=value2
[123_2]
key3 = value3
[123_1]
key4=value4";

            var parser = new IniDataParser();

            parser.Configuration.AllowDuplicateKeys = true;
            parser.Configuration.AllowDuplicateSections = true;
            parser.Configuration.AllowKeysWithoutSection = true;

            var iniData = parser.Parse(data);

            Assert.That(iniData.Sections.ContainsSection("123_1"), Is.True);
            Assert.That(iniData.Sections.ContainsSection("123_2"), Is.True);
            Assert.That(iniData.Sections.GetSectionData("123_1").Keys, Has.Count(3));
            Assert.That(iniData["123_1"]["key4"], Is.EqualTo("value4"));

        }
        static void Main()
        {
            LogFile.WriteLine("main", "читаем конфиг");
            proces = "читаем конфиг";

            IniParser.Parser.IniDataParser aa = new IniParser.Parser.IniDataParser();
            Tables.ADVERTISMENT          = aa.Parse(File.ReadAllText("config.ini"))["db"]["ADVERTISMENT"].ToString();
            Tables.ARTICLES              = aa.Parse(File.ReadAllText("config.ini"))["db"]["ARTICLES"].ToString();
            Tables.AUTHORS               = aa.Parse(File.ReadAllText("config.ini"))["db"]["AUTHORS"].ToString();
            Tables.BALANCE               = aa.Parse(File.ReadAllText("config.ini"))["db"]["BALANCE"].ToString();
            Tables.CATEGORIES            = aa.Parse(File.ReadAllText("config.ini"))["db"]["CATEGORIES"].ToString();
            Tables.COLLECTION            = aa.Parse(File.ReadAllText("config.ini"))["db"]["COLLECTION"].ToString();
            Tables.LIKES                 = aa.Parse(File.ReadAllText("config.ini"))["db"]["LIKES"].ToString();
            Tables.POLZOVATELI           = aa.Parse(File.ReadAllText("config.ini"))["db"]["POLZOVATELI"].ToString();
            Tables.PROMO_CATEGORIES_LINK = aa.Parse(File.ReadAllText("config.ini"))["db"]["PROMO_CATEGORIES_LINK"].ToString();
            Tables.READ_OF_ARTICLES      = aa.Parse(File.ReadAllText("config.ini"))["db"]["READ_OF_ARTICLES"].ToString();
            Tables.SETTINGS              = aa.Parse(File.ReadAllText("config.ini"))["db"]["SETTINGS"].ToString();
            Tables.UNIQUE                = aa.Parse(File.ReadAllText("config.ini"))["db"]["UNIQUE"].ToString();
            Tables.DEFAULT               = aa.Parse(File.ReadAllText("config.ini"))["db"]["DEFAULT"].ToString();
            Configs.ReadTableNames();



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 s = new Form1();

            s.Show();
            SQLClass.OpenConnection();
            Application.Run(new GhostMainForm());

            SQLClass.CloseConnection();
        }
Exemplo n.º 5
0
        public void GeyKey_data_retrieval()
        {
            var input = @"
            global = 1
            [section]
            key = 2
            ";
            var data = new IniDataParser().Parse(input);
            var separator = data.SectionKeySeparator;
            string key;

            // should succeed
            key = "global";
            Assert.AreEqual(data.GetKey(key), "1");

            key = string.Format("section{0}key", separator);
            Assert.AreEqual(data.GetKey(key), "2");

            // should fail
            key = null;
            Assert.IsNull(data.GetKey(key));

            key = "badglobal";
            Assert.IsNull(data.GetKey(key));

            key = string.Format("badsection{0}badkey", separator);
            Assert.IsNull(data.GetKey(key));
        }
Exemplo n.º 6
0
 public static string GetUsernameFromHgrc(string repoPath)
 {
     var hgrc = Path.Combine(repoPath, ".hg", "hgrc");
     var parser = new IniDataParser();
     var iniData = parser.Parse(File.ReadAllText(hgrc));
     return iniData["ui"]["username"];
 }
Exemplo n.º 7
0
        public IniData ParseWebsiteHostFile(string content)
        {
            var parser          = new IniParser.Parser.IniDataParser();
            var websiteHostFile = parser.Parse(content);

            return(websiteHostFile);
        }
Exemplo n.º 8
0
        public void merge_multiple_inis()
        {
            var parser = new IniDataParser();
            parser.Configuration.OverrideDuplicateKeys = true;
            parser.Configuration.AllowDuplicateKeys = true;
            parser.Configuration.AllowDuplicateSections = true;

            IniData data = parser.Parse(iniFileStrA);

            Assert.That(data, Is.Not.Null);

            {
                // first file
                Assert.That(data.Global["g"], Is.EqualTo("1"));
                Assert.That(data.Sections.Count, Is.EqualTo(2), "Expected two (2) sections");

                var s0 = data.Sections.GetSectionData("s0");

                Assert.That(s0, Is.Not.Null);
                Assert.That(s0.SectionName, Is.EqualTo("s0"));
                Assert.That(s0.Keys["a"], Is.EqualTo("2"));

                var s1 = data.Sections.GetSectionData("s1");

                Assert.That(s1, Is.Not.Null);
                Assert.That(s1.SectionName, Is.EqualTo("s1"));
                Assert.That(s1.Keys["a"], Is.EqualTo("3"));
                Assert.That(s1.Keys["b"], Is.EqualTo("4"));
            }

            parser.ParseInto(iniFileStrB, data);

            {
                // merged files
                Assert.That(data.Global["g"], Is.EqualTo("11"));
                Assert.That(data.Global["j"], Is.EqualTo("a"));
                Assert.That(data.Sections.Count, Is.EqualTo(3), "Expected two (3) sections");

                var s0 = data.Sections.GetSectionData("s0");

                Assert.That(s0, Is.Not.Null);
                Assert.That(s0.SectionName, Is.EqualTo("s0"));
                Assert.That(s0.Keys["a"], Is.EqualTo("22"));
                Assert.That(s0.Keys["b"], Is.EqualTo("44"));

                var s1 = data.Sections.GetSectionData("s1");

                Assert.That(s1, Is.Not.Null);
                Assert.That(s1.SectionName, Is.EqualTo("s1"));
                Assert.That(s1.Keys["a"], Is.EqualTo("3"));
                Assert.That(s1.Keys["b"], Is.EqualTo("4"));

                var s2 = data.Sections.GetSectionData("s2");

                Assert.That(s2, Is.Not.Null);
                Assert.That(s2.SectionName, Is.EqualTo("s2"));
                Assert.That(s2.Keys["c"], Is.EqualTo("55"));
            }
        }
Exemplo n.º 9
0
        public void check_ini_writing()
        {
            IniData data = new IniDataParser(new LiberalTestConfiguration()).Parse(iniFileStr);

            Assert.That(
                data.ToString().Replace(Environment.NewLine, string.Empty),
                Is.EqualTo(iniFileStr.Replace(Environment.NewLine, string.Empty)));
        }
 public void LoadDeviceConfiguration(IDeviceRegistry deviceRegistry)
 {
     var config = new IniDataParser().Parse(File.ReadAllText(kDeviceConfigurationFileName));
      foreach (var section in config.Sections) {
     var type = section.Keys["type"];
     var device = deviceLoadersByType[type](section);
     deviceRegistry.AddDevice(section.SectionName, device);
      }
 }
Exemplo n.º 11
0
        public void commentchar_property_works()
        {
            var parser = new IniDataParser();

            parser.Configuration.CommentChar = '#';

            var result = parser.Parse(initest);
            Assert.That(result.Sections.GetSectionData("seccion1").Comments.Count > 0);
        }
Exemplo n.º 12
0
        public void allow_duplicated_keys_in_section()
        {
            var parser = new IniDataParser();

            parser.Configuration.AllowDuplicateKeys = true;

            IniData data = parser.Parse(ini_duplicated_keys);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Sections.GetSectionData("seccion1").Keys.Count, Is.EqualTo(1));
            Assert.That(data.Sections.GetSectionData("seccion1").Keys["value1"], Is.EqualTo("10.6"));
        }
Exemplo n.º 13
0
        public void allow_backslashes_in_sections()
        {
            string data =
            @"[section\subsection]
            key=value";
            IniDataParser parser = new IniDataParser();

            IniData parsedData = parser.Parse(data);

            Assert.That(parsedData.Sections.ContainsSection("section\\subsection"));
            Assert.That(parsedData.Sections["section\\subsection"]["key"], Is.EqualTo("value"));
        }
        public void check_data_correctly_parsed()
        {
            var parser = new IniDataParser();
            IniData data = parser.Parse(iniFileStr);

            Assert.That(data, Is.Not.Null);

            // Check global section

            Assert.That(data.Global["global key"], Is.EqualTo("global value"));

            // global section is not computed when counting the number of sections in the
            // ini
            Assert.That(data.Sections.Count, Is.EqualTo(2),"Expected two (2) sections");
            var section1 = data.Sections.GetSectionData("section1");

            Assert.That(section1, Is.Not.Null);
            Assert.That(section1.SectionName, Is.EqualTo("section1"));
            Assert.That(section1.LeadingComments, Is.Not.Empty);
            Assert.That(section1.LeadingComments.Count, Is.EqualTo(1));

            Assert.That(section1.Keys, Is.Not.Null);
            Assert.That(section1.Keys.Count, Is.EqualTo(2));
            Assert.That(section1.Keys.GetKeyData("key 1"), Is.Not.Null);

            // Check keys / values with spaces. Leading & trailing whitespace ignored
            Assert.That(section1.Keys["key 1"], Is.EqualTo("value 1"));


            Assert.That(section1.Keys.GetKeyData("key;2"), Is.Not.Null);
            // Check special characters as part of the key/value name
            Assert.That(section1.Keys["key;2"], Is.EqualTo("va:lu;e.5"));


            //
            var section2 = data.Sections.GetSectionData("section2");
            // Bad section name
            Assert.That(section2, Is.Null);

            // Beware: leading and trailing whitespaces are ignored!
            section2 = data.Sections.GetSectionData("section 2");
            Assert.That(section2, Is.Not.Null);
            Assert.That(section2.SectionName, Is.EqualTo("section 2"));
            Assert.That(section2.LeadingComments, Is.Empty);
            Assert.That(section2.TrailingComments, Is.Not.Empty);
            Assert.That(section2.Comments, Is.Not.Empty);

            // Check comments at the end of the section are parsed and assigned to the section
            Assert.That(section2.TrailingComments.Count, Is.EqualTo(1));
            Assert.That(section2.TrailingComments[0], Is.EqualTo("comment for section2"));
        }
        public void check_ini_writing()
        {
            IniData data =  new IniDataParser().Parse(iniFileStr);

            // ini file string with not-needed whitespace trimmed
            var dataAsString = data.ToString();

            // Generates a valid data file
            IniData data2 = new IniDataParser().Parse(dataAsString);


            // check all strings are equal
            Assert.That(dataAsString, Is.EqualTo(data2.ToString()));
        }
Exemplo n.º 16
0
        public EngineConfigs(string customConfigs)
        {
            var parser = new IniDataParser();
            _iniData = parser.Parse(DefaultEngineConfigs);

            if (!string.IsNullOrEmpty(customConfigs))
            {
                if (customConfigs.Trim() != "")
                {
                    var userIniData = parser.Parse(customConfigs);
                    _iniData.Merge(userIniData);
                }
            }
        }
        public void parse_case_insensitive_names_ini_file()
        {
            string iniData = @"[TestSection]
            KEY1 = value1
            KEY2 = value2";

            var config = new IniParserConfiguration();
            config.CaseInsensitive = true;
            var data = new IniDataParser(config).Parse(iniData);

            Assert.That(data["testsection"]["key1"], Is.EqualTo("value1"));
            Assert.That(data["testSection"]["Key2"], Is.EqualTo("value2"));

        }
Exemplo n.º 18
0
        public void allow_whitespace_in_section_names()
        {
            string data =
@"[Web Colaboration]
key = value";

            var parser = new IniDataParser();

            IniData iniData = parser.Parse(data);

            Assert.That(iniData.Sections.Count, Is.EqualTo(1));
            Assert.That(iniData.Sections.ContainsSection("Web Colaboration"), Is.True);
            Assert.That(iniData.Sections["Web Colaboration"].ContainsKey("key"), Is.True);
            Assert.That(iniData.Sections["Web Colaboration"]["key"], Is.EqualTo("value"));
        }
        public void ReflectionConfigGenerator_GenerateConfigFile_LoadFromFile()
        {
            var file = generator.GenerateConfigFile(new ReflectionConfigGenerator.GeneratorConfig()
            {
                Type = typeof(ConfigTest)
            });
            var text   = File.ReadAllText(TestContext.CurrentContext.TestDirectory + "/config.ini");
            var parser = new IniParser.Parser.IniDataParser();
            var data   = parser.Parse(text);

            file.PullFrom(data);
            Assert.AreEqual(" ", ConfigTest.Test);
            Assert.AreEqual(0, ConfigTest.Testing.Length);
            Assert.AreEqual(112, ConfigTest.Test2);
        }
Exemplo n.º 20
0
        public void check_can_parse_special_characters_in_section_names()
        {
            string data =
            @"[{E3729302-74D1-11D3-B43A-00AA00CAD128}]
            key = value";

            var parser = new IniDataParser();

            IniData iniData = parser.Parse(data);

            Assert.That(iniData.Sections.Count, Is.EqualTo(1));
            Assert.That(iniData.Sections.ContainsSection("{E3729302-74D1-11D3-B43A-00AA00CAD128}"), Is.True);
            Assert.That(iniData.Sections["{E3729302-74D1-11D3-B43A-00AA00CAD128}"].ContainsKey("key"), Is.True);
            Assert.That(iniData.Sections["{E3729302-74D1-11D3-B43A-00AA00CAD128}"]["key"], Is.EqualTo("value"));
        }
Exemplo n.º 21
0
        public void check_can_read_keys_with_no_section()
        {
            string data =
            @"key1=value1
            key2=value2
            key3=value3";

            var parser = new IniDataParser();

            IniData iniData = parser.Parse(data);

            Assert.That(iniData.Global.Count, Is.EqualTo(3));
            Assert.That(iniData.Global["key1"], Is.EqualTo("value1"));
            Assert.That(iniData.Global["key2"], Is.EqualTo("value2"));
            Assert.That(iniData.Global["key3"], Is.EqualTo("value3"));
        }
Exemplo n.º 22
0
        public void check_deep_clone()
        {
            var input = @"
            global = 1
            [section]
            key = 1
            ";
            var ori = new IniDataParser().Parse(input);

            var copy = (IniData)ori.Clone();

            copy.Global["global"] = "2";
            copy["section"]["key"] = "2";

            Assert.That(ori.Global["global"], Is.EqualTo("1"));
            Assert.That(ori["section"]["key"], Is.EqualTo("1"));
        }
Exemplo n.º 23
0
      public void TryGetKey_preconditions()
      {
        var data = new IniDataParser().Parse("");
        var separator = data.SectionKeySeparator;
        string result;
        
        // ensure that various good keys aren't rejected
        var goodKey = "";
        Assert.DoesNotThrow(() => data.TryGetKey(goodKey, out result));
        goodKey = "key";
        Assert.DoesNotThrow(() => data.TryGetKey(goodKey, out result));
        goodKey = string.Format("section{0}key", separator);
        Assert.DoesNotThrow(() => data.TryGetKey(goodKey, out result));

        // should be rejected
        var badKey = string.Format("section{0}subsection{0}key", separator);
        Assert.Throws<ArgumentException>(() => data.TryGetKey(badKey, out result));
      }
Exemplo n.º 24
0
    private void ParseINI(string iniText)
    {
        var parser = new IniParser.Parser.IniDataParser();

        this.iniData = parser.Parse(iniText);

        foreach (SectionData block in iniData.Sections)
        {
            string blockId = block.Keys["ID"];
            if (blockId == null)
            {
                blockId = block.Keys["id"];
            }
            this.blocks.Add(new BlockInfo(
                                block,
                                (blockId != null) ? this.GetIniBlockType(Convert.ToInt32(blockId)) : ""
                                ));
        }
    }
Exemplo n.º 25
0
        static void Main()
        {
            LogFile.WriteLine("main", "читаем конфиг");
            IniParser.Parser.IniDataParser aa = new IniParser.Parser.IniDataParser();
            Tables.ADVERTISMENT = aa.Parse(File.ReadAllText("config.ini"))["db"]["ADVERTISMENT"].ToString();
            Tables.ARTICLES     = aa.Parse(File.ReadAllText("config.ini"))["db"]["ARTICLES"].ToString();
            Tables.AUTHORS      = aa.Parse(File.ReadAllText("config.ini"))["db"]["AUTHORS"].ToString();
            Tables.BALANCE      = aa.Parse(File.ReadAllText("config.ini"))["db"]["BALANCE"].ToString();
            Tables.CATEGORIES   = aa.Parse(File.ReadAllText("config.ini"))["db"]["CATEGORIES"].ToString();



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            SQLClass.OpenConnection();

            Application.Run(new GhostMainForm());
            SQLClass.CloseConnection();
        }
Exemplo n.º 26
0
    public static T Read <T>(string section, string filepath) where T : class
    {
        if (!File.Exists(filepath))
        {
            return(null);
        }

        T ret = (T)Activator.CreateInstance(typeof(T));

        var parser      = new IniParser.Parser.IniDataParser();
        var config      = parser.Parse(File.ReadAllText(filepath));
        var sectionData = config.Sections[section];

        foreach (var n in typeof(T).GetFields())
        {
            if (n.FieldType == typeof(int))
            {
                if (sectionData.ContainsKey(n.Name))
                {
                    var value = sectionData[n.Name];
                    n.SetValue(ret, int.Parse(value));
                }
            }
            else if (n.FieldType == typeof(bool))
            {
                if (sectionData.ContainsKey(n.Name))
                {
                    var value = sectionData[n.Name];
                    n.SetValue(ret, bool.Parse(value));
                }
            }
            else if (n.FieldType == typeof(string))
            {
                if (sectionData.ContainsKey(n.Name))
                {
                    var value = sectionData[n.Name];
                    n.SetValue(ret, value);
                }
            }
        }

        return(ret);
    }
Exemplo n.º 27
0
      public void TryGetKey_data_retrieval()
      {
        var input = @"
global = 1
[section1]
key1 = 2

[section1\subsection]
key2 = 3
";
        var data = new IniDataParser().Parse(input);
        var separator = data.SectionKeySeparator;
        string key;
        string result;

        // keys should all be retrieved
        Assert.IsTrue(data.TryGetKey("global", out result));
        Assert.AreEqual(result, "1");
        
        key = string.Format("section1{0}key1", separator);
        Assert.IsTrue(data.TryGetKey(key, out result));
        Assert.AreEqual(result, "2");
        
        key = string.Format(@"section1\subsection{0}key2", separator);
        Assert.IsTrue(data.TryGetKey(key, out result));
        Assert.AreEqual(result, "3");

        // invalid keys should fail...
        Assert.IsFalse(data.TryGetKey(null, out result));
        Assert.That(result, Is.Empty);

        Assert.IsFalse(data.TryGetKey("", out result));
        Assert.That(result, Is.Empty);
        
        Assert.IsFalse(data.TryGetKey("badglobal", out result));
        Assert.That(result, Is.Empty);
        
        key = string.Format("badsection{0}badkey", separator);
        Assert.IsFalse(data.TryGetKey(key, out result));
        Assert.That(result, Is.Empty);
      }
Exemplo n.º 28
0
        public void parse_ini_string_with_default_configuration()
        {
            var parser = new IniDataParser();
            IniData data = parser.Parse(iniFileStr);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Sections.Count, Is.EqualTo(2));
            var section1= data.Sections.GetSectionData("section1");

            Assert.That(section1, Is.Not.Null);
            Assert.That(section1.SectionName, Is.EqualTo("section1"));
            Assert.That(section1.LeadingComments, Is.Not.Empty);
            Assert.That(section1.LeadingComments.Count, Is.EqualTo(1));

            Assert.That(section1.Keys, Is.Not.Null);
            Assert.That(section1.Keys.Count, Is.EqualTo(2));
            Assert.That(section1.Keys.GetKeyData("key1"), Is.Not.Null);
            Assert.That(section1.Keys["key1"], Is.EqualTo("value1"));
            Assert.That(section1.Keys.GetKeyData("key2"), Is.Not.Null);
            Assert.That(section1.Keys["key2"], Is.EqualTo("value5"));
        }
Exemplo n.º 29
0
        public void delete_all_comments()
        {
            string iniData = @";comment1
            key1 = 2
            ;comment2
            [section1]

            ;a value
            value1 = 10.6";

            var data = new IniDataParser().Parse(iniData);

            Assert.That(data.Global.GetKeyData("key1").Comments, Is.Not.Empty);
            Assert.That(data.Sections.GetSectionData("section1").Comments, Is.Not.Empty);
            Assert.That(data["section1"].GetKeyData("value1").Comments, Is.Not.Empty);

            data.ClearAllComments();

            Assert.That(data.Global.GetKeyData("key1").Comments, Is.Empty);
            Assert.That(data.Sections.GetSectionData("section1").Comments, Is.Empty);
            Assert.That(data["section1"].GetKeyData("value1").Comments, Is.Empty);
        }
Exemplo n.º 30
0
        public void merge_parsed_ini_files()
        {
            var parser = new IniDataParser();

            IniData dataA = parser.Parse(iniFileStrA);

            IniData dataB = parser.Parse(iniFileStrB);

            dataA.Merge(dataB);

            {
                // merged files
                Assert.That(dataA.Global["g"], Is.EqualTo("11"));
                Assert.That(dataA.Global["j"], Is.EqualTo("a"));
                Assert.That(dataA.Sections.Count, Is.EqualTo(3), "Expected two (3) sections");

                var s0 = dataA.Sections.GetSectionData("s0");

                Assert.That(s0, Is.Not.Null);
                Assert.That(s0.SectionName, Is.EqualTo("s0"));
                Assert.That(s0.Keys["a"], Is.EqualTo("22"));
                Assert.That(s0.Keys["b"], Is.EqualTo("44"));

                var s1 = dataA.Sections.GetSectionData("s1");

                Assert.That(s1, Is.Not.Null);
                Assert.That(s1.SectionName, Is.EqualTo("s1"));
                Assert.That(s1.Keys["a"], Is.EqualTo("3"));
                Assert.That(s1.Keys["b"], Is.EqualTo("4"));

                var s2 = dataA.Sections.GetSectionData("s2");

                Assert.That(s2, Is.Not.Null);
                Assert.That(s2.SectionName, Is.EqualTo("s2"));
                Assert.That(s2.Keys["c"], Is.EqualTo("55"));
            }

        }
Exemplo n.º 31
0
        public void check_ini_writing()
        {
            IniData data =  new IniDataParser().Parse(iniFileStr);

            Assert.That(data.ToString(), Is.EqualTo(iniFileStr));
        }
Exemplo n.º 32
0
        public void escape_comment_regex_special_characters()
        {
            var iniStr = @"[Section]
                \Backslash Bcomment
                Key=Value";
         
            var parser = new IniDataParser();
            parser.Configuration.CommentString = @"\";

            parser.Parse(iniStr);
        }
Exemplo n.º 33
0
 public void Setup()
 {
     parser = new IniDataParser();
 }
Exemplo n.º 34
0
        public void escape_section_regex_special_characters()
        {
            var iniStr = @"\section\
                ;comment
                key=value";

            var parser = new IniDataParser();
            parser.Configuration.SectionStartChar = '\\';
            parser.Configuration.SectionEndChar = '\\';

            var iniData = parser.Parse(iniStr);

            Assert.That(iniData["section"]["key"], Is.EqualTo("value"));
        }
Exemplo n.º 35
0
 public void setup()
 {
     _parser = new IniDataParser(new LiberalTestConfiguration());
 }
Exemplo n.º 36
0
        public void simple_configuration()
        {
            var iniStr = @"[section1]
#data = 1
;data = 2";

            var config = new DefaultIniParserConfiguration();

            config.CommentString = "#";

            _parser = new IniDataParser(config);

            var iniData = _parser.Parse(iniStr);

            Assert.That(iniData["section1"][";data"], Is.EqualTo("2"));

        }