Пример #1
0
 public DocumentSearcher(DocumentSearcherOptions options, IDocumentTreeView documentTreeView, IDotNetImageService dotNetImageService, SearchResultContext searchResultContext)
 {
     if (options.Filter == null)
     {
         throw new ArgumentException("options.Filter is null", nameof(options));
     }
     if (options.SearchComparer == null)
     {
         throw new ArgumentException("options.SearchComparer is null", nameof(options));
     }
     this.options            = options.Clone();
     cancellationTokenSource = new CancellationTokenSource();
     cancellationToken       = cancellationTokenSource.Token;
     filterSearcherOptions   = new FilterSearcherOptions {
         Dispatcher           = Dispatcher.CurrentDispatcher,
         DocumentTreeView     = documentTreeView,
         DotNetImageService   = dotNetImageService,
         Filter               = options.Filter,
         SearchComparer       = options.SearchComparer,
         OnMatch              = r => AddSearchResult(r),
         Context              = searchResultContext,
         CancellationToken    = cancellationToken,
         SearchDecompiledData = options.SearchDecompiledData,
     };
 }
Пример #2
0
        void StartSearch()
        {
            if (!CanSearch)
            {
                Clear();
                return;
            }

            CancelSearch();
            if (string.IsNullOrEmpty(SearchText))
            {
                SearchResults.Clear();
            }
            else
            {
                var options = new DocumentSearcherOptions {
                    SearchComparer       = CreateSearchComparer(),
                    Filter               = new FlagsDocumentTreeNodeFilter(selectedSearchTypeVM.Flags),
                    SearchDecompiledData = SearchSettings.SearchDecompiledData,
                };
                fileSearcher = fileSearcherProvider.Create(options, documentTreeView);
                fileSearcher.SyntaxHighlight     = SearchSettings.SyntaxHighlight;
                fileSearcher.Decompiler          = Decompiler;
                fileSearcher.OnSearchCompleted  += FileSearcher_OnSearchCompleted;
                fileSearcher.OnNewSearchResults += FileSearcher_OnNewSearchResults;

                switch ((SearchLocation)SearchLocationVM.SelectedItem)
                {
                case SearchLocation.AllFiles:
                    fileSearcher.Start(GetAllFilesToSearch());
                    break;

                case SearchLocation.SelectedFiles:
                    fileSearcher.Start(GetSelectedFilesToSearch());
                    break;

                case SearchLocation.AllFilesInSameDir:
                    fileSearcher.Start(GetAllFilesInSameDirToSearch());
                    break;

                case SearchLocation.SelectedType:
                    fileSearcher.Start(GetSelectedTypeToSearch());
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }
        }
Пример #3
0
        public IDocumentSearcher Create(DocumentSearcherOptions options, IDocumentTreeView documentTreeView)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (documentTreeView == null)
            {
                throw new ArgumentNullException(nameof(documentTreeView));
            }
            var searchResultContext = new SearchResultContext {
                SyntaxHighlight = true,
                Decompiler      = decompilerService.Decompiler,
            };

            return(new DocumentSearcher(options, documentTreeView, dotNetImageService, searchResultContext));
        }
Пример #4
0
        public IDocumentSearcher Create(DocumentSearcherOptions options, IDocumentTreeView documentTreeView)
        {
            if (options is null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (documentTreeView is null)
            {
                throw new ArgumentNullException(nameof(documentTreeView));
            }
            var searchResultContext = new SearchResultContext(classificationFormatMap, textElementProvider, decompilerService.Decompiler)
            {
                SyntaxHighlight = true,
            };

            return(new DocumentSearcher(options, documentTreeView, dotNetImageService, searchResultContext));
        }
Пример #5
0
 void StartSearch()
 {
     CancelSearch();
     if (string.IsNullOrEmpty(SearchText))
     {
         SearchResults.Clear();
     }
     else
     {
         var options = new DocumentSearcherOptions {
             SearchComparer       = SearchComparerFactory.Create(SearchText, CaseSensitive, MatchWholeWords, MatchAnySearchTerm),
             Filter               = filter,
             SearchDecompiledData = false,
         };
         fileSearcher = fileSearcherProvider.Create(options, documentTreeView);
         fileSearcher.SyntaxHighlight     = SyntaxHighlight;
         fileSearcher.Decompiler          = Language.Decompiler;
         fileSearcher.OnSearchCompleted  += FileSearcher_OnSearchCompleted;
         fileSearcher.OnNewSearchResults += FileSearcher_OnNewSearchResults;
         fileSearcher.Start(documentTreeView.TreeView.Root.DataChildren.OfType <DsDocumentNode>());
     }
 }