Last active
January 15, 2019 18:59
-
-
Save cromica/654841159e3c6d04f23b880be01072d0 to your computer and use it in GitHub Desktop.
tell me search data provider sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QuickInfoSearchDataProvider : ISearchDataProvider | |
{ | |
public string Name => "info"; | |
public Icon ProviderIcon => PluginResources.info_1930258; | |
public static Engine Instance { get; } = new Engine( | |
typeof(Engine).Assembly, | |
typeof(Ip).Assembly); | |
public IEnumerable<ISearchDataProvider> GetProviderForQuery(string query) | |
{ | |
if (query.ToLower().Contains(Name)) yield return this; | |
} | |
public IEnumerable<ITellMeAction> SearchForSuggestion(string query) | |
{ | |
var queryInfo = new Query(query); | |
var answers = Instance.GetResults(queryInfo); | |
foreach (var (processorName, resultNode) in answers) | |
{ | |
var actions = QuickInfoActionRenderer.GenerateActions(processorName, resultNode); | |
foreach (var action in actions) | |
{ | |
yield return action; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment