Exemplo n.º 1
0
        private static IEnumerable <IScanHit> GetScanHits(string filePath, string content, 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();

            foreach (char c in content)
            {
                if (stopper != null && stopper())
                {
                    break;
                }
                finder.AnalyzeNextCharacter(c, callback);
            }

            finder.Finish(callback);

            return(hits);
        }
Exemplo n.º 2
0
        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);
        }