public static Grefs Parse(TextReader reader, int?pid = null, GrefParseOptions options = 0) { var r = new Grefs() { ParseOptions = options, }; var h = r.CreateHandlers(pid); int lineNumber = 0; string line; while ((line = reader.ReadLine()) != null) { lineNumber++; foreach (var e in h) { var m = e.Key.Match(line); if (m.Success) { e.Value(m, lineNumber); break; } } } return(r); }
void LogWarning(GrefParseOptions type, string message) { Console.WriteLine("Warning: {0}", message); GrefParseOptions shouldThrow = type | GrefParseOptions.ThrowExceptionOnMismatch; if ((ParseOptions & shouldThrow) == shouldThrow) { throw new InvalidOperationException(message); } }
public static Grefs Parse(string filename, int?pid = null, GrefParseOptions options = 0) { using (var source = new StreamReader(filename)) return(Parse(source, pid, options)); }