public void AddToMarketplaceList(MarketplaceList list) { MarketplaceList newItemsList = new MarketplaceList(); foreach (MarketplaceQueryItem queryItem in results) { newItemsList.Add(queryItem.ConvertToItem()); } list.AddRange(newItemsList); }
public async static Task <MarketplaceList> ParseTolist(MarketplaceQuery query) { MarketplaceList items = new MarketplaceList(); query.AddParam("start", 0); query.AddParam("count", 100); string responseBody = await Client.GetStringAsync(query.Uri); MarketplaceQueryResponse response = JsonSerializer.Deserialize <MarketplaceQueryResponse>(responseBody); Console.Write("Query 1 sent. "); Console.WriteLine("Returned {0} items", response.results.Count); response.AddToMarketplaceList(items); int count = response.total_count; if (count > 100) { try { for (int pos = 100; pos <= count; pos += 100) { Console.WriteLine("({0}/{1})", pos, count); Thread.Sleep(Delay); query.AddParam("start", pos); Console.Write("Query {0} sent. ", pos / 100 + 1); items.AddRange(await ParsePage(query)); } } catch (HttpRequestException e) { Console.WriteLine("\nException Caught!"); Console.WriteLine("Message :{0}", e.Message); Console.WriteLine("Saving {0} items", items.Count); } } return(items); }