private void OnHistoryChanged(object sender, EventArgs e) { if (RToolsSettings.Current.ClearFilterOnAddHistory) { SearchHost.SearchAsync(null); } }
private void OnHistoryChanged(object sender, EventArgs e) { var settings = Services.GetService <IRSettings>(); if (settings.ClearFilterOnAddHistory) { SearchHost.SearchAsync(null); } }
void UpdateSearchHost(bool enabled, string query) { if (SearchHost != null) { SearchHost.IsEnabled = enabled; if (SearchHost.SearchQuery?.SearchString != query) { SearchHost.SearchAsync(query != null ? new SearchQuery(query) : null); } } }
protected override void OnStart(string[] args) { try { if (_useWCF) { if (_wcfServer != null) { _wcfServer.Close(); } SearchHost.ValidateConfig(); // since we want our searchhost object to last as long as the process does // (keep files open), we make one instance of it and give that to the ServiceHost _searcher = new SearchHost(); _wcfServer = new ServiceHost(_searcher); var binding = Toolkit.GetSearchEngineBinding(null); var address = Toolkit.GetSearchEngineAddress(null); if (binding != null && address != null) { _wcfServer.AddServiceEndpoint(typeof(ISearchHost), binding, address.Uri); _wcfServer.Open(); } else { throw new InvalidOperationException(getDisplayMember("onstart{nowcf}", "No valid WCF end points are defined. Check SearchEngineBindingType and SearchEngineBindingUrl configuration settings.")); } } else { if (_tcpServer != null) { _tcpServer.Stop(); } SearchHost.ValidateConfig(); var port = _address != null && _address.Uri != null ? _address.Uri.Port : 2012; _searcher = new SearchHost(); _tcpServer = new TcpSearchServer(port, _searcher); _tcpServer.Start(); } base.OnStart(args); } catch (Exception ex) { EventLog.WriteEntry("Error starting GRIN-Global Search Engine: " + ex.Message, EventLogEntryType.Error); throw; } }
public ProjectExplorerControl(IVsWindowSearchHostFactory windowSearchHostFactory, ProjectExplorerViewModel viewModel) { ThreadHelper.ThrowIfNotOnUIThread(); DataContext = viewModel; InitializeComponent(); ViewModel.PropertyChanged += OnViewModelPropertyChanged; SearchHost = windowSearchHostFactory.CreateWindowSearchHost(SearchControlHost); SearchHost.SetupSearch(this); UpdateSearchEnabled(); }
void UpdateSearchHost(bool enabled, string query) { ThreadHelper.ThrowIfNotOnUIThread(); if (SearchHost != null) { SearchHost.IsEnabled = enabled; if (SearchHost.SearchQuery?.SearchString != query) { SearchHost.SearchAsync(query != null ? new SearchQuery(query) : null); } } }
void UpdateSearchHost(bool enabled, string query) { if (SearchHost != null) { SearchHost.IsEnabled = enabled; var searchString = SearchHost.SearchQuery?.SearchString; if (searchString?.Trim() != query?.Trim()) { // SearchAsync will crash the process if we send it a duplicate string. // There is a SearchTrimsWhitespace setting that makes searched with leading or trailing // white-space appear as duplicates. We compare the query with trimmed white-space to avoid this. // https://github.com/github/VisualStudio/issues/1948 SearchHost.SearchAsync(query != null ? new SearchQuery(query) : null); } } }
protected override void OnStop() { if (_searcher != null) { _searcher.Dispose(); _searcher = null; } if (_useWCF) { if (_wcfServer != null) { _wcfServer.Close(); _wcfServer = null; } } else { if (_tcpServer != null) { _tcpServer.Stop(); _tcpServer = null; } } }
public static void Shutdown() { DefaultHost.ShutdownHost(); SearchHost.ShutdownHost(); DevHost.ShutdownHost(); }
private void btnToggle_Click(object sender, EventArgs e) { var bindingType = Toolkit.GetSearchEngineBindingType(); var useWCF = !String.IsNullOrEmpty(bindingType) && bindingType.ToLower() != "tcp"; var address = Toolkit.GetSearchEngineAddress(null); if (useWCF) { if (_wcfServer == null) { _itemsToAdd = new List <ProgressEventArgs>(); _searcher = new SearchHost(new SearchHost.ProgressEventHandler(Form1_OnProgress)); _wcfServer = new ServiceHost(_searcher, new Uri[] { }); var binding = Toolkit.GetSearchEngineBinding(null); if (binding != null && address != null) { _wcfServer.AddServiceEndpoint(typeof(ISearchHost), binding, address.Uri); _itemsToAdd.Add(new ProgressEventArgs("WCF Server Listening on " + address.Uri, System.Diagnostics.EventLogEntryType.Information, false)); } else { _itemsToAdd.Add(new ProgressEventArgs("Could not initiate WCF Server, no binding or address is configured.", System.Diagnostics.EventLogEntryType.Error, true)); } } if (_wcfServer.State != CommunicationState.Opened) { // HTTP could not register URL http://+:2011/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). // Solution (for Vista only): // from an admin command prompt, run the following: // netsh http add urlacl url=http://+:2011/ user=[your username] _wcfServer.Open(); //background((sentBy, args) => { // _host.Open(); //}); btnToggle.Text = "Stop Hosting"; } else { _searcher.Dispose(); _wcfServer.Close(); _wcfServer = null; //background((sentBy, args) => { // _host.Close(); // _host = null; //}); btnToggle.Text = "Start Hosting"; } } else { if (_tcpServer == null) { _itemsToAdd = new List <ProgressEventArgs>(); _searcher = new SearchHost(new SearchHost.ProgressEventHandler(Form1_OnProgress)); _tcpServer = new TcpSearchServer(address.Uri.Port, _searcher); if (address != null) { _itemsToAdd.Add(new ProgressEventArgs("Basic TCP Server Listening on " + address.Uri, System.Diagnostics.EventLogEntryType.Information, false)); } else { _itemsToAdd.Add(new ProgressEventArgs("Could not initiate Basic TCP Server, no binding or address is configured.", System.Diagnostics.EventLogEntryType.Error, true)); } } if (!_tcpServer.IsListening) { // HTTP could not register URL http://+:2011/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). // Solution (for Vista only): // from an admin command prompt, run the following: // netsh http add urlacl url=http://+:2011/ user=[your username] _tcpServer.Start(); //background((sentBy, args) => { // _host.Open(); //}); btnToggle.Text = "Stop Hosting"; } else { _searcher.Dispose(); _tcpServer.Stop(); _tcpServer = null; //background((sentBy, args) => { // _host.Close(); // _host = null; //}); btnToggle.Text = "Start Hosting"; } } }