public static bool ParseHeadingLine(string line, Action<string, string, string> onHeadingLine) { if (string.IsNullOrWhiteSpace(line)) { return false; } var stringReader = new StringReader(line); var item1 = stringReader.TakeWhile(c => !c.IsWhiteSpace()); if (!stringReader.PeekChar().IsWhiteSpace()) { return false; } stringReader.SkipWhiteSpace(); var item2 = stringReader.TakeWhile(c => !c.IsWhiteSpace()); if (!stringReader.PeekChar().IsWhiteSpace()) { return false; } stringReader.SkipWhiteSpace(); var item3 = stringReader.ReadToEnd(); onHeadingLine(item1, item2, item3); return true; }
public static bool ParseHeaderLine(string line, Action<string, string> onHeaderLine) { var stringReader = new StringReader(line); stringReader.SkipWhiteSpace(); var header = stringReader.TakeWhile(c => c != '\x3A'); if (stringReader.PeekChar() != '\x3A') { return false; } stringReader.Read(); stringReader.SkipWhiteSpace(); var value = stringReader.ReadToEnd(); onHeaderLine(header, value ?? string.Empty); return true; }