Ejemplo n.º 1
0
        public async Task Save(LocalMylist playlist)
        {
            var fileAccessor = _PlaylistFileAccessorMap[playlist.Id];
            await fileAccessor.Save(playlist);

            await HohoemaApp.PushToRoamingData(await fileAccessor.TryGetFile());
        }
Ejemplo n.º 2
0
        public async Task Save(LocalMylist playlist)
        {
            if (_PlaylistFileAccessorMap.ContainsKey(playlist.Id))
            {
                var fileAccessor = _PlaylistFileAccessorMap[playlist.Id];
                await fileAccessor.Save(playlist);

                var file = await fileAccessor.TryGetFile();

                if (file != null)
                {
                    await HohoemaApp.PushToRoamingData(file);
                }
            }
        }
Ejemplo n.º 3
0
        internal async void RenamePlaylist(LocalMylist playlist, string newName)
        {
            var fileAccessor = _PlaylistFileAccessorMap[playlist.Id];

            // 古いファイルを同期から削除
            var oldFile = await fileAccessor.TryGetFile();

            await HohoemaApp.RoamingDataRemoved(oldFile);

            // ファイル名を変更して保存
            var newFileName = Util.FilePathHelper.ToSafeFilePath(Path.ChangeExtension(newName, ".json"));
            await fileAccessor.Rename(newFileName, forceReplace : true);

            playlist.Name = newName;

            await Save(playlist);
        }
Ejemplo n.º 4
0
        public async Task RemovePlaylist(LocalMylist playlist)
        {
            if (_Playlists.Contains(playlist))
            {
                _Playlists.Remove(playlist);
                var fileAccessor = _PlaylistFileAccessorMap[playlist.Id];

                var file = await fileAccessor.TryGetFile();

                await HohoemaApp.RoamingDataRemoved(file);

                await fileAccessor.Delete().ConfigureAwait(false);

                _PlaylistFileAccessorMap.Remove(playlist.Id);

                playlist.Dispose();
            }
        }
Ejemplo n.º 5
0
        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);
        }