public static OrderingList ParseFromFile(string filepath, bool shouldUpdate) { var lines = File.ReadLines(filepath).ToList(); var ol = new OrderingList(filepath, shouldUpdate, lines); var ln = 0; foreach (var line in lines) { ln++; if (string.IsNullOrWhiteSpace(line)) { continue; } if (line.Trim().StartsWith("#")) { continue; } if (line.Trim().StartsWith("//")) { continue; } var match = REX_LINE.Match(line); if (!match.Success) { throw new Exception($"Could nat parse order file '{filepath}'. Invalid data in line {ln}."); } var extractor = match.Groups["extractor"].Value; var id = match.Groups["id"].Value; var date = match.Groups["date"].Value; var comment = match.Groups["comment"].Value; ol._data.Add(new OrderEntry(extractor, id, date, comment)); } return(ol); }
public OrderingList GetOrdering() { return(OrderFilename != null?OrderingList.ParseFromFile(FullOrderFilename, UpdateOrderFile) : null); }