Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<Line> Parse()
- {
- try
- {
- using (StreamReader Reader = new StreamReader(PATH))
- {
- List<Line> Lines = new List<Line>();
- Regex Trim = new Regex(@"SMER:");
- Regex Direction = new Regex(@".*SMER:\s*([^\n\r]*)");
- Regex Time = new Regex(@"\d{2}:\d{2}");
- while (!Reader.EndOfStream)
- {
- string line = Reader.ReadLine();
- if (!String.IsNullOrWhiteSpace(line))
- {
- if (Direction.IsMatch(line))
- {
- Lines.Last().Directions.Add(new Direction(Trim.Replace(line, ""), new List<string>()));
- }
- else if (Time.IsMatch(line))
- {
- Lines.Last().Directions.Last().Times.Add(line);
- }
- else
- {
- Lines.Add(new Line(line, new List<Direction>()));
- }
- }
- }
- return Lines;
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- throw;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement