private async void ImportData_Click(object sender, RoutedEventArgs e) { FileOpenPicker picker = new FileOpenPicker { SuggestedStartLocation = PickerLocationId.MusicLibrary }; picker.FileTypeFilter.Add(".json"); StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { MainPage.Instance.Loader.ShowIndeterminant("ProcessRequest"); try { string json = await FileIO.ReadTextAsync(file); Settings settings = JsonFileHelper.Convert <Settings>(json); bool successful = await UpdateMusicLibrary(); MainPage.Instance.Loader.Hide(); MainPage.Instance.ShowLocalizedNotification(successful ? "DataImported" : "ImportDataCancelled"); } catch (Exception ex) { MainPage.Instance.Loader.Hide(); MainPage.Instance.ShowLocalizedNotification("ImportDataFailed" + ex.Message); } } }
public static async Task Init() { if (AlbumInfoList != null) { return; } var albums = JsonFileHelper.Convert <List <AlbumInfo> >(await JsonFileHelper.ReadAsync(JsonFilename)); if (albums == null) { AlbumInfoList = new List <AlbumInfo>(); } else { AlbumInfoList = albums; } }
public static async Task Init() { Log = JsonFileHelper.Convert <UpdateLog>(await JsonFileHelper.ReadAsync(JsonFileName)) ?? new UpdateLog(); }