public static async Task Inicializar() { if (multasRealizadas == null) { multasRealizadas = await objectStorageHelper.LoadAsync() ?? new ListaDeMultasRealizadas(); } }
private async void ConnectView_Loaded(object sender, RoutedEventArgs e) { serversOSH = new ObjectStorageHelper <ObservableCollection <String> >(StorageType.Roaming); servers = await serversOSH.LoadAsync(Config.ServersStore); serversListOSH = new ObjectStorageHelper <List <Net.IrcServer> >(StorageType.Roaming); serversList = await serversListOSH.LoadAsync(Config.ServersListStore); serversSavedCombo.ItemsSource = servers; }
public async Task<BindableCollection<ResultViewModel>> Initialize() { _objectStorageHelper = new ObjectStorageHelper<List<ResultViewModel>>(StorageType.Local); var storageList = await _objectStorageHelper.LoadAsync(); var result = new BindableCollection<ResultViewModel>(); foreach (var item in storageList) result.Add(item); return result; }
public async Task SaveAndDeletePocoWithAHandle() { var osh = new ObjectStorageHelper <Poco>(StorageType.Local); var poco = new Poco(); await osh.SaveAsync(poco, handle); await osh.DeleteAsync(handle); var result = await osh.LoadAsync(handle); Assert.AreEqual(result, default(Poco)); }
public async Task AttemptToLoadObjectUsingAHandleThatDoesNotExist() { //new up ObjectStorageHelper specifying that we want to interact with the Local storage folder var osh = new ObjectStorageHelper <Poco>(StorageType.Local); //First ensure that it does not exist await osh.DeleteAsync(handle); //Get the object from the storage folder var myPoco = await osh.LoadAsync(handle); Assert.AreEqual(null, myPoco); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // code to check whether user was logged in or not check = await DoesFileExistAsync("Drive2Wellness.Model.objStorageHelperDrive2Wellness.Model.objStorageHelper"); if (check) { var helper_objStorage = new ObjectStorageHelper <objStorageHelper>(StorageType.Local); objStorageHelper retrivedObject = await helper_objStorage.LoadAsync(); App.userName = retrivedObject.username; rootFrame.Navigate(typeof(MainPage)); } else { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(Login), args.Arguments)) { throw new Exception("Failed to create initial page"); } } } SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested; // Ensure the current window is active Window.Current.Activate(); }
public async Task SaveAndLoadTwoObjectsOfSameTypeUsingDifferentHandles() { var poco = new Poco() { IntProp = 1, StringProp = "one" }; var anotherPoco = new Poco() { IntProp = 2, StringProp = "two" }; var osh = new ObjectStorageHelper <Poco>(StorageType.Local); await osh.SaveAsync(poco, handle); await osh.SaveAsync(anotherPoco, handle2); var result = await osh.LoadAsync(handle); var anotherResult = await osh.LoadAsync(handle2); Assert.AreEqual(poco, result); Assert.AreEqual(anotherPoco, anotherResult); }
public async Task SaveListOfObjectsWhenObjectClassIsDefinedInAnotherProject() { var listOfPocos = new List <Poco>(); listOfPocos.Add(new Poco()); listOfPocos.Add(new Poco()); var osh = new ObjectStorageHelper <List <Poco> >(StorageType.Local); await osh.SaveAsync(listOfPocos); var result = await osh.LoadAsync(); CollectionAssert.AreEqual(listOfPocos, result); }
public async Task SaveAndLoadPocoUsingAHandle() { var poco = new Poco() { IntProp = 1, StringProp = "one" }; var osh = new ObjectStorageHelper <Poco>(StorageType.Local); await osh.SaveAsync(poco, handle); var result = await osh.LoadAsync(handle); Assert.AreEqual(poco, result); }
public async Task SaveAndLoadListOfPocosUsingAHandle() { var listOfPocos = new List <Poco>(); listOfPocos.Add(new Poco()); listOfPocos.Add(new Poco()); var osh = new ObjectStorageHelper <List <Poco> >(StorageType.Local); await osh.SaveAsync(listOfPocos, handle); var result = await osh.LoadAsync(handle); CollectionAssert.AreEqual(listOfPocos, result); }
public async Task SaveAndLoadTwoObjectsOfDifferentTypesUsingTheSameHandle() { var poco = new Poco() { IntProp = 1, StringProp = "one" }; var poco2 = new Poco2() { IntProp = 2, StringProp = "two" }; var osh = new ObjectStorageHelper <Poco>(StorageType.Local); var osh2 = new ObjectStorageHelper <Poco2>(StorageType.Local); await osh.SaveAsync(poco, handle); await osh2.SaveAsync(poco2, handle); var result = await osh.LoadAsync(handle); var result2 = await osh2.LoadAsync(handle); Assert.AreEqual(poco, result); Assert.AreEqual(poco2, result2); }
public async Task <T> Load <T>(string handle) { var objectStorageHelper = new ObjectStorageHelper <T>(StorageType.Roaming); return(await objectStorageHelper.LoadAsync(handle)); }
private async Task GetCards() { var loader = new ObjectStorageHelper<List<Card>>(StorageType.Roaming); //await loader.DeleteAsync("Cards"); var cards = await loader.LoadAsync("Cards"); if (cards != null) SimpleIoc.Default.GetInstance<MainViewModel>().Cards = new ObservableCollection<Card>(cards); }
/// <summary> /// Charge un utilisateur depuis l'espace de stockage local /// </summary> /// <param name="userNickname">nom de l'utilisateur à charger</param> /// <returns></returns> public static async Task <User> LoadUserFromTemporaryStorage(string userNickname) { var osh = new ObjectStorageHelper <User>(StorageType.Temporary); return(await osh.LoadAsync(userNickname)); }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { try { PivotItem p = new PivotItem(); lastAuto = true; p.Header = "Welcome"; Frame frame = new Frame(); p.Margin = new Thickness(0, 0, 0, -2); p.Content = frame; Tabs.Items.Add(p); Tabs.SelectedIndex = Tabs.Items.Count - 1; frame.Navigate(typeof(PlaceholderView)); UpdateUi(); //ChannelFrame.Navigate(typeof(PlaceholderView)); // blank the frame serversOSH = new ObjectStorageHelper <ObservableCollection <String> >(StorageType.Roaming); serversListOSH = new ObjectStorageHelper <List <Net.IrcServer> >(StorageType.Roaming); var folder = serversOSH.GetFolder(StorageType.Roaming); if ((await folder.GetItemsAsync()).Count == 0 && !(await serversOSH.FileExists(folder, "migrated"))) { await folder.CreateFileAsync("migrated", CreationCollisionOption.FailIfExists); return; } if ((await folder.GetItemsAsync()).Count == 1) { return; } if (await serversOSH.FileExists(folder, "migrated")) { servers = await serversOSH.LoadAsync(Config.ServersStore); serversList = await serversListOSH.LoadAsync(Config.ServersListStore); } else { servers = await serversOSH.LoadAsync(); await serversOSH.MigrateAsync(servers, Config.ServersStore); serversList = await serversListOSH.LoadAsync(); await serversListOSH.MigrateAsync(serversList, Config.ServersListStore); await folder.CreateFileAsync("migrated", CreationCollisionOption.FailIfExists); } } catch (Exception ex) { var dialog = new MessageDialog("Error when loading saved servers: " + ex.Message); await dialog.ShowAsync(); } }
public async Task <T> Load <T>() { var objectStorageHelper = new ObjectStorageHelper <T>(UsedStorageType); return(await objectStorageHelper.LoadAsync()); }