예제 #1
0
        protected async virtual Task <IEnumerable <UnsplashImageBase> > RequestAsync(int pageIndex)
        {
#if DEBUG
            var cts = CTSFactory.MakeCTS();
#else
            var cts = CTSFactory.MakeCTS(15000);
#endif
            try
            {
                var result = await CloudService.GetImages(pageIndex, (int)20u, cts.Token, RequestUrl);

                if (result.IsRequestSuccessful)
                {
                    IEnumerable <UnsplashImageBase> list = null;
                    if (Featured)
                    {
                        list = UnsplashFeaturedImage.ParseListFromJson(result.JsonSrc);
                    }
                    else
                    {
                        list = UnsplashImage.ParseListFromJson(result.JsonSrc);
                    }
                    await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        UpdateHintVisibility(list);
                    });

                    return(list);
                }
                else
                {
                    throw new ArgumentNullException();
                }
            }
            catch (Exception e)
            {
                await Logger.LogAsync(e);

                return(new List <UnsplashImage>());
            }
        }
        protected async virtual Task <IEnumerable <UnsplashImageBase> > RequestAsync(int pageIndex)
        {
            var result = await CloudService.GetImages(pageIndex, (int)DEFAULT_PER_PAGE, CTSFactory.MakeCTS(10000).Token, RequestUrl);

            if (result.IsRequestSuccessful)
            {
                if (Featured)
                {
                    var list = UnsplashFeaturedImage.ParseListFromJson(result.JsonSrc);
                    UpdateHintVisibility(list);
                    return(list);
                }
                else
                {
                    var list = UnsplashImage.ParseListFromJson(result.JsonSrc);
                    UpdateHintVisibility(list);
                    return(list);
                }
            }
            else
            {
                throw new APIException();
            }
        }