private static IEnumerable <IScanHit> GetScanHits(string filePath, string content, MatchFinder finder, ScanStopper stopper) { List <IScanHit> hits = new List <IScanHit>(); MatchFoundCallback callback = delegate(ISearchTerm term, int line, int column, string lineText, string warning) { hits.Add(new ScanHit(filePath, line, column, lineText, term, warning)); }; finder.Reset(); foreach (char c in content) { if (stopper != null && stopper()) { break; } finder.AnalyzeNextCharacter(c, callback); } finder.Finish(callback); return(hits); }
private static IEnumerable <IScanHit> GetScanHits(string filePath, StreamReader reader, MatchFinder finder, ScanStopper stopper) { List <IScanHit> hits = new List <IScanHit>(); MatchFoundCallback callback = (term, line, column, lineText, warning) => hits.Add(new ScanHit(filePath, line, column, lineText, term, warning)); finder.Reset(); while (!reader.EndOfStream) { if (stopper != null && stopper()) { break; } finder.AnalyzeNextCharacter((char)reader.Read(), callback); } finder.Finish(callback); return(hits); }