public static IList<IniFileCategory> ReadIniFile(Stream stream)
        {
            var result = new List<IniFileCategory>(0x1000);

            using (StreamReader sr = new StreamReader(stream))
            {
                IniFileCategory cat = null;
                string line;
                while (null != (line = sr.ReadLine()))
                {
                    {
                        Match m = Regex.Match(line, @"^\s*\[(?<name>[^]]+)\]\s*$", RegexOptions.Compiled);
                        if (m.Success)
                        {
                            cat = new IniFileCategory();
                            cat.Name = m.Groups["name"].Value;
                            result.Add(cat);
                            continue;
                        }
                    }

                    if (null == cat)
                    {
                        continue;
                    }

                    {
                        Match m = Regex.Match(line, "^(?<key>[^=]+)=\"?(?<value>[^\"]*)\"?$", RegexOptions.Compiled);
                        if (m.Success)
                        {
                            cat.Items.Add(m.Groups["key"].Value, m.Groups["value"].Value);
                        }
                    }
                }
            }
            return result;
        }
 public void Test1()
 {
     var cat = new IniFileCategory();
     Assert.AreEqual(null, cat.Name);
     Assert.AreEqual(0, cat.Items.Count);
 }