public LocalMylist CreatePlaylist(string id, string name) { var sortIndex = _Playlists.Count > 0 ? _Playlists.Max(x => x.SortIndex) + 1 : 0; var playlist = new LocalMylist(id, name) { HohoemaPlaylist = this, SortIndex = sortIndex }; var playlistFileAccessor = new FileAccessor <LocalMylist>(PlaylistsSaveFolder, playlist.Name + ".json"); _PlaylistFileAccessorMap.Add(playlist.Id, playlistFileAccessor); _Playlists.Add(playlist); playlistFileAccessor.Save(playlist).ConfigureAwait(false); return(playlist); }
public async Task SaveDownloadRequestItems() { if (!IsInitialized) { return; } using (var pendingVideoLockReleaser = await _CacheDownloadPendingVideosLock.LockAsync()) { if (CacheDownloadPendingVideos.Count > 0) { await _CacheRequestedItemsFileAccessor.Save(CacheDownloadPendingVideos); Debug.WriteLine("ダウンロードリクエストを保存しました。"); } else { if (await _CacheRequestedItemsFileAccessor.Delete()) { Debug.WriteLine("ダウンロードリクエストがないため、ファイルを削除しました。"); } } } }