private void QuerySuggestions(string keyword, Query query, string subtitle, WebSearch webSearch) { ISuggestionSource sugg = SuggestionSourceFactory.GetSuggestionSource(WebSearchStorage.Instance.WebSearchSuggestionSource, context); if (sugg != null) { var result = sugg.GetSuggestions(keyword); if (result != null) { context.API.PushResults(query, context.CurrentPluginMetadata, result.Select(o => new Result() { Title = o, SubTitle = subtitle, Score = 5, IcoPath = webSearch.IconPath, Action = (c) => { Process.Start(webSearch.Url.Replace("{q}", Uri.EscapeDataString(o))); return(true); } }).ToList()); } } }
private IEnumerable <Result> ResultsFromSuggestions(string keyword, string subtitle, WebSearch webSearch) { ISuggestionSource sugg = SuggestionSourceFactory.GetSuggestionSource(_settings.WebSearchSuggestionSource, Context); var suggestions = sugg?.GetSuggestions(keyword); if (suggestions != null) { var resultsFromSuggestion = suggestions.Select(o => new Result { Title = o, SubTitle = subtitle, Score = 5, IcoPath = webSearch.IconPath, Action = c => { Process.Start(webSearch.Url.Replace("{q}", Uri.EscapeDataString(o))); return(true); } }); return(resultsFromSuggestion); } return(new List <Result>()); }
protected override List <Result> QueryInternal(Query query) { List <Result> results = new List <Result>(); WebSearch webSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled); if (webSearch != null) { string keyword = query.ActionParameters.Count > 0 ? query.GetAllRemainingParameter() : ""; string title = keyword; string subtitle = "Search " + webSearch.Title; if (string.IsNullOrEmpty(keyword)) { title = subtitle; subtitle = null; } context.API.PushResults(query, context.CurrentPluginMetadata, new List <Result>() { new Result() { Title = title, SubTitle = subtitle, Score = 6, IcoPath = webSearch.IconPath, Action = (c) => { Process.Start(webSearch.Url.Replace("{q}", Uri.EscapeDataString(keyword))); return(true); } } }); if (UserSettingStorage.Instance.EnableWebSearchSuggestion && !string.IsNullOrEmpty(keyword)) { ISuggestionSource sugg = SuggestionSourceFactory.GetSuggestionSource( UserSettingStorage.Instance.WebSearchSuggestionSource); if (sugg != null) { var result = sugg.GetSuggestions(keyword); if (result != null) { context.API.PushResults(query, context.CurrentPluginMetadata, result.Select(o => new Result() { Title = o, SubTitle = subtitle, Score = 5, IcoPath = webSearch.IconPath, Action = (c) => { Process.Start(webSearch.Url.Replace("{q}", Uri.EscapeDataString(o))); return(true); } }).ToList()); } } } } return(results); }