コード例 #1
0
        private static void ParseIni(IObject iniObj, TextReader textReader)
        {
            if (iniObj == null)
            {
                throw new ArgumentNullException("iniObj");
            }

            if (textReader == null)
            {
                throw new ArgumentNullException("textReader");
            }

            ISection tempSection = null;

            while (textReader.Peek() != -1)
            {
                string line = textReader.ReadLine();
                if (string.IsNullOrEmpty(line) == false && Regices[2].IsMatch(line) == false)
                {
                    Match match = Regices[0].Match(line);
                    if (match.Success)
                    {
                        tempSection = new ISection(match.Groups[1].Value);
                        iniObj.Add(tempSection);
                        continue;
                    }

                    match = Regices[1].Match(line);
                    if (match.Success)
                    {
                        tempSection.Add(match.Groups[1].Value.Trim(), match.Groups[2].Value);
                    }
                }
            }
        }