Example #1
0
 private IAsyncOperation <LoadItemsResult <Gallery> > loadCore(bool reIn)
 {
     return(AsyncInfo.Run(async token =>
     {
         var doc = await Client.Current.HttpClient.GetDocumentAsync(DomainProvider.Eh.RootUri);
         var pp = doc.GetElementbyId("pp");
         if (pp is null) // Disabled popular
         {
             if (reIn)
             {
                 return LoadItemsResult.Empty <Gallery>();
             }
             else
             {
                 await DomainProvider.Eh.Settings.FetchAsync();
                 await DomainProvider.Eh.Settings.SendAsync();
                 return await loadCore(true);
             }
         }
         var nodes = (from div in pp.Elements("div")
                      where div.HasClass("id1")
                      select div).ToList();
         var ginfo = nodes.Select(n =>
         {
             var link = n.Descendants("a").First().GetAttribute("href", default(Uri));
             return GalleryInfo.Parse(link);
         }).ToList();
         var galleries = await Gallery.FetchGalleriesAsync(ginfo);
         for (var i = 0; i < ginfo.Count; i++)
         {
             handleAdditionalInfo(nodes[i], galleries[i]);
         }
         return LoadItemsResult.Create(0, galleries);
     }));
 }