Exemplo n.º 1
0
 public override Task GetResults(ISearchResultCallback searchResultCallback, SearchPopupSearchPattern pattern, CancellationToken token)
 {
     return(Task.Run(delegate {
         var files = AllFiles.ToList();
         var matcher = StringMatcher.GetMatcher(pattern.Pattern, false);
         var savedMatches = new Dictionary <string, MatchResult> ();
         foreach (ProjectFile file in files)
         {
             if (token.IsCancellationRequested)
             {
                 break;
             }
             int rank;
             string matchString = System.IO.Path.GetFileName(file.FilePath);
             if (MatchName(savedMatches, matcher, matchString, out rank))
             {
                 searchResultCallback.ReportResult(new FileSearchResult(pattern.Pattern, matchString, rank, file, true));
             }
             matchString = FileSearchResult.GetRelProjectPath(file);
             if (MatchName(savedMatches, matcher, matchString, out rank))
             {
                 searchResultCallback.ReportResult(new FileSearchResult(pattern.Pattern, matchString, rank, file, true));
             }
         }
     }, token));
 }