mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-07-02 00:57:38 +00:00
Each command can format the mpd response. User response is a MpdMessage which conatins the requested command and the formatted response.
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
namespace LibMpc
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LibMpc
|
||||
{
|
||||
public partial class Commands
|
||||
{
|
||||
@ -10,7 +12,7 @@
|
||||
/// <summary>
|
||||
/// Turns an output off.
|
||||
/// </summary>
|
||||
public class DisableOutput : IMpcCommand
|
||||
public class DisableOutput : IMpcCommand<string>
|
||||
{
|
||||
private readonly int _outputId;
|
||||
|
||||
@ -21,16 +23,16 @@
|
||||
|
||||
public string Value => string.Join(" ", "disableoutput", _outputId);
|
||||
|
||||
public object ParseResponse(object response)
|
||||
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns an output on.
|
||||
/// </summary>
|
||||
public class EnableOutput : IMpcCommand
|
||||
public class EnableOutput : IMpcCommand<string>
|
||||
{
|
||||
private readonly int _outputId;
|
||||
|
||||
@ -41,9 +43,9 @@
|
||||
|
||||
public string Value => string.Join(" ", "enableoutput", _outputId);
|
||||
|
||||
public object ParseResponse(object response)
|
||||
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,13 +54,27 @@
|
||||
/// <summary>
|
||||
/// Shows information about all outputs.
|
||||
/// </summary>
|
||||
public class Outputs : IMpcCommand
|
||||
public class Outputs : IMpcCommand<Dictionary<string, string>>
|
||||
{
|
||||
public string Value => "outputs";
|
||||
|
||||
public object ParseResponse(object response)
|
||||
public IReadOnlyDictionary<string, IList<Dictionary<string, string>>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
var result = new Dictionary<string, IList<Dictionary<string, string>>>
|
||||
{
|
||||
{"outputs", new List<Dictionary<string, string>>()}
|
||||
};
|
||||
|
||||
for (var i = 0; i < response["outputid"].Count; i++)
|
||||
{
|
||||
result["outputs"].Add(new Dictionary<string, string>
|
||||
{
|
||||
{ "id", response["outputid"][i] },
|
||||
{ "name", response["outputname"][i] },
|
||||
{ "enabled", response["outputenabled"][i] }
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user