public static bool Matches(this ILineReader reader, Func <string, string> comparer) { ILineReaderEntry entry = reader.Current; if (entry == null) { return(false); } return(comparer(entry.Text) != null); }
public void Flush(ILineReaderEntry stopAt = null) { if (stopAt != null) { m_index = (stopAt as EntryWrapper).Index; } else { m_index = m_list.Count; } m_current = null; }
public static string Find(this ILineReader reader, [Implicit] ICallContext context, Func <string, string> comparer, bool flushIfNotFound = false) { var peaker = reader.Peak(); ILineReaderEntry last = null; foreach (var entry in peaker) { var result = comparer(entry.Text); if (result != null) { reader.Flush(entry); return(result); } last = entry; } if (flushIfNotFound) { reader.Flush(last); // First flush until the last seen entry reader.Next(); // ... then also flush the last seen. } return(null); }