mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-07-01 08:47:36 +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,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LibMpc
|
||||
{
|
||||
@ -10,8 +10,8 @@ namespace LibMpc
|
||||
public class Database
|
||||
{
|
||||
// TODO: count
|
||||
|
||||
public class Find : IMpcCommand
|
||||
|
||||
public class Find : IMpcCommand<string>
|
||||
{
|
||||
private readonly ITag _tag;
|
||||
private readonly string _searchText;
|
||||
@ -24,13 +24,13 @@ namespace LibMpc
|
||||
|
||||
public string Value => string.Join(" ", "find", _tag.Value, _searchText);
|
||||
|
||||
public object ParseResponse(object response)
|
||||
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public class List : IMpcCommand
|
||||
public class List : IMpcCommand<string>
|
||||
{
|
||||
private readonly ITag _tag;
|
||||
|
||||
@ -41,15 +41,15 @@ namespace LibMpc
|
||||
|
||||
public string Value => string.Join(" ", "list", _tag);
|
||||
|
||||
public object ParseResponse(object response)
|
||||
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: findadd
|
||||
|
||||
public class ListAll : IMpcCommand
|
||||
public class ListAll : IMpcCommand<string>
|
||||
{
|
||||
private readonly string _path;
|
||||
|
||||
@ -60,9 +60,9 @@ namespace LibMpc
|
||||
|
||||
public string Value => string.Join(" ", "listall", _path);
|
||||
|
||||
public object ParseResponse(object response)
|
||||
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,16 +74,16 @@ namespace LibMpc
|
||||
// TODO: searchadd
|
||||
// TODO: searchaddpl
|
||||
|
||||
public class Update : IMpcCommand
|
||||
public class Update : IMpcCommand<string>
|
||||
{
|
||||
public string Value => "update";
|
||||
|
||||
public object ParseResponse(object response)
|
||||
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: rescan
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace LibMpc
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LibMpc
|
||||
{
|
||||
public partial class Commands
|
||||
{
|
||||
@ -11,13 +13,13 @@
|
||||
// TODO: commands
|
||||
// TODO: notcommands
|
||||
|
||||
public class TagTypes : IMpcCommand
|
||||
public class TagTypes : IMpcCommand<string>
|
||||
{
|
||||
public string Value => "tagtypes";
|
||||
|
||||
public object ParseResponse(object response)
|
||||
public IReadOnlyDictionary<string, IList<string>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LibMpc
|
||||
{
|
||||
public interface IMpcCommand
|
||||
public interface IMpcCommand<T>
|
||||
{
|
||||
string Value { get; }
|
||||
|
||||
// TODO: Return IMpdResponse and create type-safe input.
|
||||
object ParseResponse(object response);
|
||||
IReadOnlyDictionary<string, IList<T>> FormatResponse(IReadOnlyDictionary<string, IList<string>> response);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user