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); }
public void Add(IniSection section) { _sections.Add(section); }