public static VConfig Parse(string[] lines, string file) { var r_section = new Regex(@"^\[([A-Za-z0-9_]+)\]$"); var r_item = new Regex(@"^([A-Za-z0-9_]+)=([^=]*)$"); var cfg = new VConfig(new VCSection[0], new FileInfo(file)); string section = "Default"; cfg.Add(section); foreach (string line in lines) { Match m = r_section.Match(line); if (m.Success) { section = m.Groups[1].Value; if (!cfg.SectionExist(section)) { cfg.Add(section); } } else if ((m = r_item.Match(line)).Success) { cfg.GetSection(section).Add(m.Groups[1].Value, m.Groups[2].Value); } } return(cfg); }
public static VConfig Create(string file) { var cfg = new VConfig(new VCSection[0], new FileInfo(file)); cfg.Add("Default"); return(cfg); }