Skip to main content

Get search results

To get search results for a specific model, call the FindResultByModel method of the ISearchManager object. The ISearchManager object can be obtained using the IApplication.Search property.

public void FindResultByModel(ICommandContext c, ICommandParams p) 
{
//Get the target model
var model = c.App.Workspace.CurrentModel;

//Get the search results
ISearchManager searchManager = c.App.Search;
ISearchResultEntryCollection resultEntries = searchManager.FindResultByModel(model);

//Output the search results
foreach (ISearchResultEntry resultEntry in resultEntries)
{
c.App.Output.WriteLine("sample", $"Search results: {resultEntry.Message}");
}
}