//加载数据 private async Task LoadData() { ServiceLocator.BuildLocator(); var context = ServiceLocator.Resolve <Context>(); var user = await StorageHelper.ReadLocal(o => SerializeExtension.JsonDeserlialize <User>(o)); var token = await StorageHelper.ReadLocal(o => SerializeExtension.JsonDeserlialize <AuthToken>(o)); if (token != null) { token = await ServiceLocator.Resolve <Api.OAuthorAPI>().RefreshToken(token); } context.User = user; if (token != null && token.ExpiresIn > DateTime.Now) { await context.SetToken(token); } //var user = await StorageHelper.ReadLocal(o => SerializeExtension.JsonDeserlialize<User>(o)); //var token = await StorageHelper.ReadLocal(o => SerializeExtension.JsonDeserlialize<AuthToken>(o)); //if (token != null) //{ // token = await AppContext.API.OAuthorAPI.RefreshToken(token); //} //AppContext.User = user; //if (token != null && token.ExpiresIn > DateTime.Now) //{ // await AppContext.SetToken(token); //} }
//加载数据 private async Task LoadData() { var user = await StorageHelper.ReadLocal(o => SerializeExtension.JsonDeserlialize <User>(o)); var token = await StorageHelper.ReadLocal(o => SerializeExtension.JsonDeserlialize <AuthToken>(o)); if (token != null) { token = await AppContext.API.OAuthorAPI.RefreshToken(token); //UserItem.Special = true; } AppContext.User = user; if (token != null && token.ExpiresIn > DateTime.Now) { //UserItem.Special = true; await AppContext.SetToken(token); } //NotifyPropertyChanged("User"); }