Class SearchContext
The search context encapsulate all the states necessary to perform a query. It allows the full customization of how a query would be performed.
Namespace: Unity.QuickSearch
Syntax
public class SearchContext : IDisposable
Constructors
SearchContext(IEnumerable<SearchProvider>)
Create a new search context.
Declaration
public SearchContext(IEnumerable<SearchProvider> providers)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<SearchProvider> | providers | The list of providers used to resolve the specified query. |
SearchContext(IEnumerable<SearchProvider>, String)
Create a new search context.
Declaration
public SearchContext(IEnumerable<SearchProvider> providers, string searchText)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<SearchProvider> | providers | The list of providers used to resolve the specified query. |
| String | searchText | The search query to perform. |
SearchContext(IEnumerable<SearchProvider>, String, SearchFlags)
Create a new search context.
Declaration
public SearchContext(IEnumerable<SearchProvider> providers, string searchText, SearchFlags options)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<SearchProvider> | providers | The list of providers used to resolve the specified query. |
| String | searchText | The search query to perform. |
| SearchFlags | options | Options to further controlled the query. |
Properties
actionId
The search action id to be executed.
Declaration
public string actionId { get; }
Property Value
| Type | Description |
|---|---|
| String |
filterId
Explicit filter id. Usually it is the first search token like h:, p: to do an explicit search for a given provider. Can be null
Declaration
public string filterId { get; }
Property Value
| Type | Description |
|---|---|
| String |
focusedWindow
Editor window that initiated the search.
Declaration
public EditorWindow focusedWindow { get; }
Property Value
| Type | Description |
|---|---|
| EditorWindow |
options
Search context options
Declaration
public SearchFlags options { get; set; }
Property Value
| Type | Description |
|---|---|
| SearchFlags |
progressId
Progress handle to set the search current progress.
Declaration
public int progressId { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
providers
Which Providers are active for this particular context.
Declaration
public IEnumerable<SearchProvider> providers { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<SearchProvider> |
searchInProgress
Indicates if an asynchronous search is currently in progress for this context.
Declaration
public bool searchInProgress { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
searchPhrase
Returns a phrase that contains only words separated by spaces
Declaration
public string searchPhrase { get; }
Property Value
| Type | Description |
|---|---|
| String |
searchQuery
Processed search query (no filterId, no textFilters)
Declaration
public string searchQuery { get; }
Property Value
| Type | Description |
|---|---|
| String |
searchText
Raw search text (i.e. what is in the search text box)
Declaration
public string searchText { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
searchView
Search view holding and presenting the search results.
Declaration
public ISearchView searchView { get; }
Property Value
| Type | Description |
|---|---|
| ISearchView |
searchWords
Search query tokenized by words. All text filters are discarded and all words are lower cased.
Declaration
public string[] searchWords { get; }
Property Value
| Type | Description |
|---|---|
| String[] |
selection
Return the search result selection if any.
Declaration
public SearchSelection selection { get; }
Property Value
| Type | Description |
|---|---|
| SearchSelection |
textFilters
All tokens containing a colon (':')
Declaration
public string[] textFilters { get; }
Property Value
| Type | Description |
|---|---|
| String[] |
wantsMore
Indicates if the search should return results as many as possible.
Declaration
public bool wantsMore { get; set; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Methods
Dispose()
Dispose of the Search Context
Declaration
public void Dispose()
Dispose(Boolean)
Dispose of the SearchContext. Will End the Search session.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | disposing | Is the SearchItem currently being disposed. |
Finalize()
Search context finalizer.
Declaration
protected void Finalize()
IsEnabled(String)
Checks if a provider is available to process a query.
Declaration
public bool IsEnabled(string providerId)
Parameters
| Type | Name | Description |
|---|---|---|
| String | providerId | If of the provider. See SearchProvider.name.id. |
Returns
| Type | Description |
|---|---|
| Boolean |
ReportProgress(Single, String)
This function is invoked during when a search is performed asynchronously to display progress.
Declaration
public void ReportProgress(float progress = 0F, string status = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | progress | Progress value. Varies between 0 and 1. |
| String | status | Current status/description of the Search. |
ResetFilter(Boolean)
Reset all provider filter to the specified value. This allows enabling or disabling all providers in one call. A disabled provider won't be ask to provider items to resolve the query.
Declaration
public void ResetFilter(bool enableAll)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | enableAll | If true enable all providers. If false disable all providers. |
SetFilter(String, Boolean)
Enable or disable a single provider. A disabled provider won't be ask to provider items to resolve the query.
Declaration
public void SetFilter(string providerId, bool isEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| String | providerId | Id of the provider. See SearchProvider.name.id. |
| Boolean | isEnabled | If true, enable the provider to perform query. |
Events
asyncItemReceived
This event is used to receive any async search result.
Declaration
public event Action<SearchContext, IEnumerable<SearchItem>> asyncItemReceived
Event Type
| Type | Description |
|---|---|
| Action<SearchContext, IEnumerable<SearchItem>> |
sessionEnded
Invoked when a Search has ended.
Declaration
public event Action<SearchContext> sessionEnded
Event Type
| Type | Description |
|---|---|
| Action<SearchContext> |
sessionStarted
Invoked when a Search is started.
Declaration
public event Action<SearchContext> sessionStarted
Event Type
| Type | Description |
|---|---|
| Action<SearchContext> |