1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2025-07-01 08:47:36 +00:00

Bug in find command fixed.

This commit is contained in:
glucaci
2016-12-20 15:42:48 +01:00
parent b12ded8121
commit ba83fbd824
4 changed files with 36 additions and 17 deletions

View File

@ -16,7 +16,7 @@ namespace LibMpc
/// <summary>
/// Finds songs in the database that is exactly "searchText".
/// </summary>
public class Find : IMpcCommand<IEnumerable<MpdFile>>
public class Find : IMpcCommand<IEnumerable<IMpdFile>>
{
private readonly ITag _tag;
private readonly string _searchText;
@ -29,25 +29,19 @@ namespace LibMpc
public string Value => string.Join(" ", "find", _tag.Value, _searchText);
public IEnumerable<MpdFile> FormatResponse(IList<KeyValuePair<string, string>> response)
public IEnumerable<IMpdFile> FormatResponse(IList<KeyValuePair<string, string>> response)
{
var results = new List<MpdFile>();
var mpdFile = MpdFile.EmptyFile;
foreach (var line in response)
{
if (line.Key.Equals("file"))
{
if (mpdFile.IsInitialized)
{
results.Add(mpdFile);
}
mpdFile = new MpdFile(line.Value);
results.Add(new MpdFile(line.Value));
}
else
{
mpdFile.AddTag(line.Key, line.Value);
results.Last().AddTag(line.Key, line.Value);
}
}