Exemple #1
0
    /// <summary>
    /// 設定ファイルを保存する。
    /// </summary>
    /// <returns></returns>
    private Task SaveSettings()
    {
        this.SettingSaving?.Invoke(this, this.Setting);

        var setting = this.Setting;

        var player  = this.MediaPlayer;
        var manager = player.MediaManager;

        var settingFilePath = this.GetLocalFilePath(Config.SettingFileName);

        var lastTrack = player.Track;

        if (lastTrack != null)
        {
            setting.LastTrackId = lastTrack.Id;
        }

        var lastPlaylist = player.Playlist as AlbumPlaylist;

        if (lastPlaylist != null)
        {
            setting.LastPlaylistId = lastPlaylist.Album.Id;
        }

        return(MessagePackUtil.SerializeFile(this.Setting, settingFilePath));
    }
Exemple #2
0
 private static async Task <T> ParseMessagePackSettingAsync <T>(string filename) where T : class
 {
     try
     {
         return(await MessagePackUtil.DeserializeFileAsync <T>(filename).ConfigureAwait(false));
     }
     catch (Exception ex)
     {
         throw new Exception($"設定ファイル \"{filename}\" の読み込みに失敗しました。\n{ex.GetMessage()}", ex);
     }
 }
Exemple #3
0
 private static async Task SaveMessagePackSetting <T>(string filename, T setting) where T : class
 {
     try
     {
         await MessagePackUtil.SerializeFileAsync(setting, filename).ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         throw new Exception($"設定 \"{filename}\" の保存に失敗しました。\n{ex.GetMessage()}", ex);
     }
 }
Exemple #4
0
    /// <summary>
    /// 設定ファイルを読み込む。
    /// </summary>
    /// <returns></returns>
    private async Task LoadSettings()
    {
        var settingFilePath = this.GetLocalFilePath(Config.SettingFileName);

        this.Setting = await MessagePackUtil.DeserializeFile <ApplicationSetting>(settingFilePath)
                       .ConfigureAwait(false);

        if (this.Setting == null)
        {
            this.Setting = new ApplicationSetting();
        }
    }