コード例 #1
0
    public void Execute(IDataContext context, DelegateExecute nextExecute)
    {
      // Get solution from context in which action is executed
      ISolution solution = context.GetData(ProjectModel.DataContext.DataConstants.SOLUTION);
      if (solution == null)
        return;

      var documentManager = solution.GetComponent<DocumentManager>();
      var shellLocks = solution.GetComponent<IShellLocks>();
      var settingStore = solution.GetComponent<ISettingsStore>();
      var mainWindow = solution.GetComponent<IMainWindow>();
      
      // Ask user about search string
      FindTextSearchRequest searchRequest;
      using (var dialog = new EnterSearchStringDialog(settingStore.BindToContextTransient(ContextRange.Smart((lt, contexts) => context))))
      {
        if (dialog.ShowDialog(mainWindow) != DialogResult.OK)
          return;

        // Create request, descriptor, perform search and show results 
        searchRequest = new FindTextSearchRequest(solution, dialog.SearchString, dialog.CaseSensitive, dialog.SearchFlags, documentManager);
      }

      using (shellLocks.UsingReadLock())
      {
        var descriptor = new FindTextDescriptor(searchRequest);
        descriptor.Search();
        FindResultsBrowser.ShowResults(descriptor);
      }
    }
コード例 #2
0
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            // Get solution from context in which action is executed
            ISolution solution = context.GetData(ProjectModel.DataContext.DataConstants.SOLUTION);

            if (solution == null)
            {
                return;
            }

            var documentManager = solution.GetComponent <DocumentManager>();
            var shellLocks      = solution.GetComponent <IShellLocks>();
            var settingStore    = solution.GetComponent <ISettingsStore>();
            var mainWindow      = solution.GetComponent <IMainWindow>();

            // Ask user about search string
            FindTextSearchRequest searchRequest;

            using (var dialog = new EnterSearchStringDialog(settingStore.BindToContextTransient(ContextRange.Smart((lt, contexts) => context))))
            {
                if (dialog.ShowDialog(mainWindow) != DialogResult.OK)
                {
                    return;
                }

                // Create request, descriptor, perform search and show results
                searchRequest = new FindTextSearchRequest(solution, dialog.SearchString, dialog.CaseSensitive, dialog.SearchFlags, documentManager);
            }

            using (shellLocks.UsingReadLock())
            {
                var descriptor = new FindTextDescriptor(searchRequest);
                descriptor.Search();
                FindResultsBrowser.ShowResults(descriptor);
            }
        }