Ejemplo n.º 1
0
        public static IniFile Parse(string[] lines)
        {
            IniFile    result  = new IniFile();
            IniSection section = null;

            char[] delimiters = { '=' };
            foreach (string line in lines)
            {
                string text = line.Trim();
                if (Utility.IsNullOrEmpty(text))
                {
                    continue;
                }
                if (text.StartsWith("["))
                {
                    text         = text.Trim('[', ']');
                    section      = new IniSection();
                    section.Name = text;
                    result.Add(section);
                }
                else
                {
                    string[] parts = text.Split(delimiters, 2);
                    string   key   = parts[0];
                    string   value = parts.Length == 2
                        ? parts[1]
                        : string.Empty;
                    IniLine item = new IniLine(key, value);
                    if (!ReferenceEquals(section, null))
                    {
                        section.Add(item);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
 public void Add(IniSection section)
 {
     _sections.Add(section);
 }