Ejemplo n.º 1
0
 private static void PrintArticles(ArticlesData articlesData)
 {
     Console.Clear();
     Console.WriteLine("The articles are:");
     foreach (Article article in articlesData.Articles)
     {
         Console.WriteLine();
         Console.WriteLine(new string('*', 20));
         Console.WriteLine("Name: {0}", article.Title);
         Console.WriteLine();
         Console.WriteLine("Url: {0}", article.Url);
     }
 }
Ejemplo n.º 2
0
        private static async void GetArticles(string searchString, int numberOfArticles, HttpClient httpClient)
        {
            HttpResponseMessage response = await httpClient.GetAsync("search.json?q=" + searchString + "&count=" + numberOfArticles);

            string articlesAsString = await response.Content.ReadAsStringAsync();

            ArticlesData articlesData = JsonConvert.DeserializeObject <ArticlesData>(articlesAsString);

            PrintArticles(articlesData);

            Console.WriteLine(new string('*', 20));
            Console.WriteLine("Press Enter for exit.");
        }