1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2025-07-02 00:57:38 +00:00

Formatting output responsability of command.

Commands: disableoutput, enableoutput, outputs, tagtypes, update implemented.
This commit is contained in:
glucaci
2016-12-07 10:34:55 +01:00
parent 4a176e8f45
commit 4ffa4bca6c
6 changed files with 50 additions and 37 deletions

View File

@ -23,9 +23,9 @@ namespace LibMpc
public string Value => string.Join(" ", "disableoutput", _outputId);
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
public IDictionary<string, string> FormatResponse(IList<KeyValuePair<string, string>> response)
{
return response;
return response.ToDefaultDictionary();
}
}
@ -43,9 +43,9 @@ namespace LibMpc
public string Value => string.Join(" ", "enableoutput", _outputId);
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
public IDictionary<string, string> FormatResponse(IList<KeyValuePair<string, string>> response)
{
return response;
return response.ToDefaultDictionary();
}
}
@ -54,23 +54,28 @@ namespace LibMpc
/// <summary>
/// Shows information about all outputs.
/// </summary>
public class Outputs : IMpcCommand<Dictionary<string, string>>
public class Outputs : IMpcCommand<IList<IDictionary<string, string>>>
{
public string Value => "outputs";
public IReadOnlyDictionary<string, IList<Dictionary<string, string>>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
public IDictionary<string, IList<IDictionary<string, string>>> FormatResponse(IList<KeyValuePair<string, string>> response)
{
var result = new Dictionary<string, IList<Dictionary<string, string>>>
var result = new Dictionary<string, IList<IDictionary<string, string>>>
{
{"outputs", new List<Dictionary<string, string>>()}
{ "outputs", new List<IDictionary<string, string>>() }
};
for (var i = 0; i < response["outputid"].Count; i++)
for (var i = 0; i < response.Count; i += 3)
{
var outputId = response[i].Value;
var outputName = response[i + 1].Value;
var outputEnabled = response[i + 2].Value;
result["outputs"].Add(new Dictionary<string, string>
{
{ "id", response["outputid"][i] },
{ "name", response["outputname"][i] },
{ "enabled", response["outputenabled"][i] }
{"id", outputId},
{"name", outputName},
{"enabled", outputEnabled}
});
}