1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2024-09-16 05:30:09 +00:00

Implement MoveId command

This commit is contained in:
Petr Kracík 2020-01-19 00:14:11 +01:00
parent e565528b33
commit 6ee33cd704

View File

@ -0,0 +1,52 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AddCommand.cs" company="MpcNET">
// Copyright (c) MpcNET. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace MpcNET.Commands.Playlist
{
using System.Collections.Generic;
/// <summary>
/// Moves the song with FROM (songid) to TO (playlist index) in the playlist.
/// If TO is negative, it is relative to the current song in the playlist (if there is one)
/// https://www.musicpd.org/doc/protocol/queue.html.
/// </summary>
public class MoveIdCommand : IMpcCommand<string>
{
private readonly int from;
private readonly int to;
/// <summary>
/// Initializes a new instance of the <see cref="MoveIdCommand"/> class.
/// </summary>
/// <param name="from">From (songid)</param>
/// <param name="to">To (playlist index)</param>
public MoveIdCommand(int from, int to)
{
this.from = from;
this.to = to;
}
/// <summary>
/// Serializes the command.
/// </summary>
/// <returns>
/// The serialize command.
/// </returns>
public string Serialize() => string.Join(" ", "moveid", from, to);
/// <summary>
/// Deserializes the specified response text pairs.
/// </summary>
/// <param name="response">The response.</param>
/// <returns>
/// The deserialized response.
/// </returns>
public string Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
{
return string.Join(", ", response);
}
}
}