예제 #1
0
        public static INIBlock Create(PeekStreamReader sr, string path)
        {
            string        str   = "";
            bool          flag  = false;
            List <string> lines = new List <string>();
            int           line  = sr.LineAt;

            while (true)
            {
                str = sr.PeekLine();
                if (str == null)
                {
                    break;
                }

                if (header.IsMatch(str))
                {
                    if (!flag)
                    {
                        flag = true;
                    }
                    else
                    {
                        break;
                    }
                }
                if (flag)
                {
                    lines.Add(str);
                }

                sr.ReadLine();
            }

            if (lines.Count == 0)
            {
                return(null);
            }

            return(new INIBlock(lines.ToArray <string>(), path, line));
        }
예제 #2
0
        private void ParseFile(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new IOException("File " + filename + " does not exist. Did the filesystem change during parsing?");
            }

            PeekStreamReader sr = new PeekStreamReader(filename);

            while (true)
            {
                INIBlock i = INIBlock.Create(sr, filename);
                if (i != null)
                {
                    blocks.Add(i);
                }
                else
                {
                    break;
                }
            }
            sr.Close();
        }