Modules/WikipediaSearchModule.cs
/// <summary>
/// Performs the action to retrieve a <see cref="SearchModuleResult"/> collection.
/// </summary>
/// <param name="query">The query to use for retrieving results.</param>
Performs the action to retrieve a  collection.
Performs the action to retrieve a collection .
public override async Task RetrieveResultsAsync(string query)
        {
            string url = string.Format(this.Url, query);
            var jsonResult = await HttpUtility.Current.Get(url);
            JArray result = JsonConvert.DeserializeObject<JArray>(jsonResult);
            if (result != null && result.Count == 4)
            {
                this.Results = new List<SearchModuleResult>();
                string[] searchResults = result[1].Select(j => j.Value<string>()).ToArray();
                string[] searchDescriptions = result[2].Select(j => j.Value<string>()).ToArray();
                string[] searchUrls = result[3].Select(j => j.Value<string>()).ToArray();
                for (int i = 0; i < this.MaxResults; i++)
                {
                    string description = $"{searchResults[i]}{Environment.NewLine}{searchDescriptions[i]}";
                    string retrievedUrl = searchUrls[i];
                    this.Results.Add(new SearchModuleResult(this.Icon, description, () => Utility.Current.OpenFile(retrievedUrl)));
                }
            }
            else
            {
                this.Results = null;
            }
        }
public override async Task RetrieveResultsAsync ( string query ) { string url = string . Format ( this . Url , query ) ; var jsonResult = await HttpUtility . Current . Get ( url ) ; JArray result = JsonConvert . DeserializeObject < JArray > ( jsonResult ) ; if ( result != null && result . Count == 4 ) { this . Results = new List < SearchModuleResult > ( ) ; string [ ] searchResults = result [ 1 ] . Select ( j => j . Value < string > ( ) ) . ToArray ( ) ; string [ ] searchDescriptions = result [ 2 ] . Select ( j => j . Value < string > ( ) ) . ToArray ( ) ; string [ ] searchUrls = result [ 3 ] . Select ( j => j . Value < string > ( ) ) . ToArray ( ) ; for ( int i = 0 ; i < this . MaxResults ; i ++ ) { string description = $" { searchResults [ i ] } { Environment . NewLine } { searchDescriptions [ i ] } " ; string retrievedUrl = searchUrls [ i ] ; this . Results . Add ( new SearchModuleResult ( this . Icon , description , ( ) => Utility . Current . OpenFile ( retrievedUrl ) ) ) ; } } else { this . Results = null ; } }
Performs the action to retrieve a  collection.
Performs the action to retrieve a collection .
query
string
The query to use for retrieving results.
The query to use for retrieving results .