예제 #1
0
        public List<NarratorItem> Parse(string file)
        {
            lines = File.ReadAllLines(file);
            items = new List<NarratorItem>();
            narratorItem = null;
            index = 0;
            separators = 0;

            while (index < lines.Length)
            {
                if (lines[index].StartsWith(separator))
                {
                    ParseSeparators();
                }
                else if (lines[index].EndsWith(":"))
                {
                    ParseOptions();
                }

                index++;

                if (index >= lines.Length)
                {
                    break;
                }
            }

            lines = null;

            return items;
        }
예제 #2
0
        private void ParseSeparators()
        {
            separators++;

            if (separators == 1)
            {
                index++;
                narratorItem = new NarratorItem();
                narratorItem.Name = lines[index];
                index++;
            }
            else if (separators == 2)
            {
                items.Add(narratorItem);
                separators = 0;

                // If we havent reached the end of the file, then adjust the index for the next item
                if (index + 1 < lines.Length)
                {
                    index -= 2;
                }
            }
        }