1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2025-07-01 08:47:36 +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

@ -30,9 +30,9 @@ namespace LibMpc
public IMpdRequest<T> Request { get; }
public IMpdResponse<T> Response { get; }
private IReadOnlyDictionary<string, IList<string>> GetValuesFromResponse()
private IList<KeyValuePair<string, string>> GetValuesFromResponse()
{
var result = new Dictionary<string, IList<string>>();
var result = new List<KeyValuePair<string, string>>();
foreach (var line in _rawResponse)
{
@ -45,14 +45,7 @@ namespace LibMpc
var mpdValue = match.Result("${value}");
if (!string.IsNullOrEmpty(mpdValue))
{
if (!result.ContainsKey(mpdKey))
{
result.Add(mpdKey, new List<string>() { mpdValue });
}
else
{
result[mpdKey].Add(mpdValue);
}
result.Add(new KeyValuePair<string, string>(mpdKey, mpdValue));
}
}
}

View File

@ -6,19 +6,19 @@ namespace LibMpc
public interface IMpdResponse<T>
{
IMpdResponseState State { get; }
IReadOnlyDictionary<string, IList<T>> Body { get; }
IDictionary<string, T> Body { get; }
}
public class MpdResponse<T> : IMpdResponse<T>
{
public MpdResponse(string endLine, IReadOnlyDictionary<string, IList<T>> body, bool connected)
public MpdResponse(string endLine, IDictionary<string, T> body, bool connected)
{
State = new MpdResponseState(endLine, connected);
Body = body;
}
public IMpdResponseState State { get; }
public IReadOnlyDictionary<string, IList<T>> Body { get; }
public IDictionary<string, T> Body { get; }
}
public static class CheckNotNullExtension