private async void SaveServicesAsync(IEnumerable <ServiceInformation> services) { var serviceFile = await RoamingFolder.CreateFileAsync( ServicesFileName, CreationCollisionOption.ReplaceExisting); using (var servicesStream = await serviceFile.OpenStreamForWriteAsync()) { _serializer.WriteObject(servicesStream, services.ToList()); } ServicesUpdated(); }
/// <summary> /// Removes all application data from the local, roaming, and temporary app data stores. /// </summary> /// <returns></returns> public Task ClearAsync() { #if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE return(_applicationData.ClearAsync().AsTask()); #else return(Task.Run(async() => { await LocalFolder?.DeleteAllItems(); LocalSettings?.Values.Clear(); await RoamingFolder?.DeleteAllItems(); RoamingSettings?.Values.Clear(); await TemporaryFolder?.DeleteAllItems(); })); #endif }
public async Task <IEnumerable <ServiceInformation> > LoadServicesAsync() { var serviceFile = await RoamingFolder.CreateFileAsync( ServicesFileName, CreationCollisionOption.OpenIfExists); using (var servicesStream = await serviceFile.OpenStreamForReadAsync()) { if (servicesStream.Length == 0) { return(Enumerable.Empty <ServiceInformation>()); } return(_serializer.ReadObject(servicesStream) as List <ServiceInformation>); } }
/// <summary> /// Removes all application data from the specified app data store. /// </summary> /// <param name="locality">One of the enumeration values.</param> /// <returns></returns> public Task ClearAsync(ApplicationDataLocality locality) { return(Task.Run(async() => { switch (locality) { case ApplicationDataLocality.Local: await LocalFolder?.DeleteAllItems(); LocalSettings?.Values.Clear(); break; case ApplicationDataLocality.Roaming: await RoamingFolder?.DeleteAllItems(); RoamingSettings?.Values.Clear(); break; case ApplicationDataLocality.Temporary: await TemporaryFolder?.DeleteAllItems(); break; } })); }