Пример #1
0
 int DetectTitleLevel(LineReader reader)
 {
     for(int i = 0; i < levelChars.Length; i++) {
         if(IsFilledWith(reader.NextLine, i))
             return i;
     }
     throw new ApplicationException("Detect and Process methods give different results.");
 }
Пример #2
0
        public bool Detect(LineReader reader)
        {
            if(reader.NextLine == null)
                return false;

            foreach(char c in levelChars) {
                if(IsFilledWith(reader.NextLine, c))
                    return true;
            }
            return false;
        }
Пример #3
0
        public List<Node> Parse(string[] lines)
        {
            var nodes = new List<Node>();
            var lineReader = new LineReader(lines);

            do {
                foreach(var nr in nodeReaders) {
                    if(nr.Detect(lineReader)) {
                        nodes.Add(nr.Process(lineReadear));
                        break;
                    }
                }

            } while(lineReader.CurrentLine != null);

            return nodes;
        }
Пример #4
0
 bool Detect(LineReader reader)
 {
     return (reader.CurrentLine == String.Empty);
 }
Пример #5
0
 Node Process(LineReader reader)
 {
     reader.Advance(1);
     return null;
 }
Пример #6
0
 public Node Process(LineReader reader)
 {
     return new Node(reader.CurrentLine, Category.Title) {
         Level = DetectTitleLevel(reader.NextLine)
     };
 }
Пример #7
0
 bool Detect(LineReader reader)
 {
     return true;
 }
Пример #8
0
 Node Process(LineReader reader)
 {
     Advance(1);
     return new Node(reader.CurrentLine, Category.Garbage);
 }
Пример #9
0
 bool Detect(LineReader reader)
 {
     return reader.CurrentLine.StartsWith("-");
 }
Пример #10
0
 Node Process(LineReader reader)
 {
     string text = reader.CurrentLine.Substring(1).Trim();
     Advance(1);
     return new Node(text, Category.Item);
 }