void loadCommonData() { var commonDataLoader = new CommonDataLoader(new RestRequestCreator()); // 20141030 // CommonData.Data = commonDataLoader.Load(); ClientSettings.Instance.CommonData.Data = commonDataLoader.Load(); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (!await HttpHelper.CheckInternet()) { Progress.Text = "加载资源失败"; await new MessageDialog("请连接互联网后重试!").ShowAsync(); Windows.UI.Xaml.Application.Current.Exit(); } HomePage.TodaysListId = await CommonDataLoader.GetGeneralList(HomePage.CumulateListIndex.ToString(), ListType.HomeList); HomePage.CumulateListIndex += 1; Progress.Text = "加载资源成功!正在初始化"; Frame.ContentTransitions = new TransitionCollection { new NavigationThemeTransition() }; NavigationManager.GeneralFrame = Frame; Frame.Navigate( ViewModelBase.CurrentSettings.SkipPreLoadPage ? typeof(MainFrameContainer) : typeof(PreLoadPage), HomePage.CurrentHomeModle = await CommonDataLoader.GetGeneralModelByIdAsync <HomeModel>(HomePage.TodaysListId[0]), new DrillInNavigationTransitionInfo()); SystemNavigationManager.GetForCurrentView().BackRequested += PreLoadPage_BackRequested; }
public async Task RefreshListView() { foreach (var item in await CommonDataLoader.GetReadingModel(0)) { ReadingModelCollection.Add(item); } }
public async Task RefreshCollection() { foreach (var item in await CommonDataLoader.GetGeneralModelsCollectionByIdAsync <CarouselModel>("")) { AddToCollection(item); } }
public async Task RefreshAMusicCollection(string id) { var model = await CommonDataLoader.GetGeneralModelByIdAsync <MusicModel>(id); await model.RefreshCommentsCollection(string.Format(ServicesUrl.MusicComment, id)); MusicModelsCollection.Add(model); }
public async Task RefreshCollection(string id) { foreach (var item in await CommonDataLoader.GetGeneralModelsCollectionByIdAsync <CarouselDetailModel>(id)) { CarouselDetailModelCollection.Add(item); } CarouselDetailModel.ResetIndex(); }
public async Task RefreshCommentsCollection(string id) { foreach (var model in await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <CommentModel>(string.Format(ServicesUrl.MovieComment, Id))) { if (model.Type == "0") { HotComments.Add(model); } else { NormalComments.Add(model); } } }
public static async Task <string> RequestUpdate() { try { var response = (await CommonDataLoader.GetGeneralList("0", ListType.HomeList)).Take(5); if (response != null) { await UpdatePrimaryTile((await CommonDataLoader.LoadHomeModelsAsync(response)).ToList()); } } catch (Exception) { throw; } return(null); }
protected async Task AddToRelatedCollection <T>(string id) { var uri = GetRelatedUri <T>(id); switch (typeof(T).Name) { case nameof(QuestionDetailPageViewModel): AddToRelatedCollection <QuestionContent, QuestionModel>( await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <QuestionContent>(uri)); return; case nameof(EssayDetailPageViewModel): AddToRelatedCollection <EssayContent, EssayModel>( await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <EssayContent>(uri)); return; case nameof(SerialDetailPageViewModel): AddToRelatedCollection <SerialContent, SerialModel>( await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <SerialContent>(uri) ); return; } }
public void Should_respond_Ok_on_getting_common_data_as_json() { var url = GIVEN_url_to_testRun_data(); _responseHeaders.Location = new Uri(BaseUrl + url); _mockRestServer.ExpectNewRequest() .AndExpectUri(BaseUrl + url) .AndExpectMethod(HttpMethod.GET) .AndRespondWith("{ \"Key\":\"aaa\",\"Value\":\"bbb\" }", _responseHeaders, HttpStatusCode.OK, ""); var commonDataLoader = new CommonDataLoader(_restRequestCreator); var resultDictionary = commonDataLoader.Load(); Assert.Equal("aaa", resultDictionary["Key"]); Assert.Equal("bbb", resultDictionary["Value"]); }
public async Task AddHomeModel(string contentId) { _homeModelCollection.Add(await CommonDataLoader.GetGeneralModelByIdAsync <HomeModel>(contentId)); }