diff --git a/LibMpc/Commands/Commands.Database.cs b/LibMpc/Commands/Commands.Database.cs
index 8cbc68e..f09c4a7 100644
--- a/LibMpc/Commands/Commands.Database.cs
+++ b/LibMpc/Commands/Commands.Database.cs
@@ -13,16 +13,16 @@ namespace LibMpc
public class Find : IMpcCommand
{
- private readonly SearchTag _searchTag;
+ private readonly ITag _tag;
private readonly string _searchText;
- public Find(SearchTag searchTag, string searchText)
+ public Find(ITag tag, string searchText)
{
- _searchTag = searchTag;
+ _tag = tag;
_searchText = searchText;
}
- public string Value => string.Join(" ", "find", _searchTag.Value, _searchText);
+ public string Value => string.Join(" ", "find", _tag.Value, _searchText);
public object ParseResponse(object response)
{
@@ -32,14 +32,14 @@ namespace LibMpc
public class List : IMpcCommand
{
- private readonly SearchTag _searchTag;
+ private readonly ITag _tag;
- public List(SearchTag searchTag)
+ public List(ITag tag)
{
- _searchTag = searchTag;
+ _tag = tag;
}
- public string Value => string.Join(" ", "list", _searchTag);
+ public string Value => string.Join(" ", "list", _tag);
public object ParseResponse(object response)
{
diff --git a/LibMpc/Enum.cs b/LibMpc/Enum.cs
deleted file mode 100644
index 8504e7a..0000000
--- a/LibMpc/Enum.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-namespace LibMpc
-{
- ///
- /// The scope specifier for search commands.
- ///
- public enum ScopeSpecifier
- {
- ///
- /// Any attribute of a file.
- ///
- Any,
- ///
- /// The path and name of the file.
- ///
- Filename,
- ///
- /// The artist of the track.
- ///
- Artist,
- ///
- /// The album the track appears on.
- ///
- Album,
- ///
- /// The title of the track.
- ///
- Title,
- ///
- /// The index of the track on its album.
- ///
- Track,
- ///
- /// The name of the track.
- ///
- Name,
- ///
- /// The genre of the song.
- ///
- Genre,
- ///
- /// The date the track was released.
- ///
- Date,
- ///
- /// The composer of the song.
- ///
- Composer,
- ///
- /// The performer of the song.
- ///
- Performer,
- ///
- /// A comment for the track.
- ///
- Comment,
- ///
- /// The disc of a multidisc album the track is on.
- ///
- Disc
- }
-
-}
\ No newline at end of file
diff --git a/LibMpc/Mpc.cs b/LibMpc/Mpc.cs
index 82d0701..751113c 100644
--- a/LibMpc/Mpc.cs
+++ b/LibMpc/Mpc.cs
@@ -156,15 +156,15 @@ namespace LibMpc
///
/// Returns all files in the database who's attribute matches the given token. Works like the Search command but is case sensitive.
///
- /// Specifies the attribute to search for.
+ /// Specifies the attribute to search for.
/// The value the files attribute must have to be included in the result.
/// All files in the database who's attribute matches the given token.
- public async Task> FindAsync(ScopeSpecifier scopeSpecifier, string token)
+ public async Task> FindAsync(ITag tag, string token)
{
if (token == null)
throw new ArgumentNullException("token");
- MpdResponse response = await _connection.Exec("find", new string[] { TagConverter.ToTag(scopeSpecifier), token });
+ MpdResponse response = await _connection.Exec("find", new string[] { tag.Value, token });
if (response.IsError)
throw new MpdResponseException(response.ErrorCode, response.ErrorMessage);
@@ -174,11 +174,11 @@ namespace LibMpc
///
/// Returns all values found in files of the MPD for the given attribute.
///
- /// The attribute who's values are requested.
+ /// The attribute who's values are requested.
/// All values found in files of the MPD for the given attribute.
- public async Task> ListAsync(ScopeSpecifier scopeSpecifier)
+ public async Task> ListAsync(ITag tag)
{
- MpdResponse response = await _connection.Exec("list", new string[] { TagConverter.ToTag(scopeSpecifier) });
+ MpdResponse response = await _connection.Exec("list", new string[] { tag.Value });
if (response.IsError)
throw new MpdResponseException(response.ErrorCode, response.ErrorMessage);
@@ -192,12 +192,12 @@ namespace LibMpc
/// The attribute whos value should match a given value for the file to be included in the result.
/// The value the searchTag attribute must match for the file to be included in the result.
/// All values found in files of the MPD for the given attribute.
- public async Task> ListAsync(ScopeSpecifier resultTag, ScopeSpecifier searchTag, string searchValue)
+ public async Task> ListAsync(ITag resultTag, ITag searchTag, string searchValue)
{
if (searchValue == null)
throw new ArgumentNullException("searchValue");
- MpdResponse response = await _connection.Exec("list", new string[] { TagConverter.ToTag(resultTag), TagConverter.ToTag(searchTag), searchValue });
+ MpdResponse response = await _connection.Exec("list", new string[] { resultTag.Value, searchTag.Value, searchValue });
if (response.IsError)
throw new MpdResponseException(response.ErrorCode, response.ErrorMessage);
@@ -270,15 +270,15 @@ namespace LibMpc
///
/// Returns all files in the database who's attribute matches the given token. Works like the Find command but is case insensitive.
///
- /// Specifies the attribute to search for.
+ /// Specifies the attribute to search for.
/// The value the files attribute must have to be included in the result.
/// All files in the database who's attribute matches the given token.
- public async Task> SearchAsync(ScopeSpecifier scopeSpecifier, string token)
+ public async Task> SearchAsync(ITag tag, string token)
{
if (token == null)
throw new ArgumentNullException("token");
- MpdResponse response = await _connection.Exec("search", new string[] { TagConverter.ToTag(scopeSpecifier), token });
+ MpdResponse response = await _connection.Exec("search", new string[] { tag.Value, token });
if (response.IsError)
throw new MpdResponseException(response.ErrorCode, response.ErrorMessage);
@@ -707,15 +707,15 @@ namespace LibMpc
///
/// Returns the meta data for all tracks in the current playlist whos attribute equals the given value.
///
- /// The attribute to search for the given value.
+ /// The attribute to search for the given value.
/// The value to search for in the given attribute.
/// The meta data for all tracks in the current playlist whos attribute equals the given value.
- public async Task> PlaylistFindAsync(ScopeSpecifier scopeSpecifier, string token)
+ public async Task> PlaylistFindAsync(ITag tag, string token)
{
if (token == null)
throw new ArgumentNullException("token");
- MpdResponse response = await _connection.Exec("playlistfind", new string[] { TagConverter.ToTag(scopeSpecifier), token });
+ MpdResponse response = await _connection.Exec("playlistfind", new string[] { tag.Value, token });
if (response.IsError)
throw new MpdResponseException(response.ErrorCode, response.ErrorMessage);
@@ -725,15 +725,15 @@ namespace LibMpc
///
/// Returns the meta data for all tracks in the current playlist whos attribute contains the given value.
///
- /// The attribute to search for the given value.
+ /// The attribute to search for the given value.
/// The value to search for in the given attribute.
/// The meta data for all tracks in the current playlist whos attribute contains the given value.
- public async Task> PlaylistSearchAsync(ScopeSpecifier scopeSpecifier, string token)
+ public async Task> PlaylistSearchAsync(ITag tag, string token)
{
if (token == null)
throw new ArgumentNullException("token");
- MpdResponse response = await _connection.Exec("playlistsearch", new string[] { TagConverter.ToTag(scopeSpecifier), token });
+ MpdResponse response = await _connection.Exec("playlistsearch", new string[] { tag.Value, token });
if (response.IsError)
throw new MpdResponseException(response.ErrorCode, response.ErrorMessage);
diff --git a/LibMpc/TagConverter.cs b/LibMpc/TagConverter.cs
deleted file mode 100644
index fabeed2..0000000
--- a/LibMpc/TagConverter.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-
-namespace LibMpc
-{
- public static class TagConverter
- {
- private const string TagAny = "any";
- private const string TagFilename = "filename";
- private const string TagArtist = "artist";
- private const string TagAlbum = "album";
- private const string TagTitle = "title";
- private const string TagTrack = "track";
- private const string TagName = "name";
- private const string TagGenre = "genre";
- private const string TagDate = "date";
- private const string TagComposer = "composer";
- private const string TagPerformer = "performer";
- private const string TagComment = "comment";
- private const string TagDisc = "disc";
-
- public static string ToTag(ScopeSpecifier scopeSpecifier)
- {
- switch (scopeSpecifier)
- {
- default:
- throw new ArgumentException("scopeSpecifier");
- case ScopeSpecifier.Any:
- return TagAny;
- case ScopeSpecifier.Filename:
- return TagFilename;
- case ScopeSpecifier.Artist:
- return TagArtist;
- case ScopeSpecifier.Album:
- return TagAlbum;
- case ScopeSpecifier.Title:
- return TagTitle;
- case ScopeSpecifier.Track:
- return TagTrack;
- case ScopeSpecifier.Name:
- return TagName;
- case ScopeSpecifier.Genre:
- return TagGenre;
- case ScopeSpecifier.Date:
- return TagDate;
- case ScopeSpecifier.Composer:
- return TagComposer;
- case ScopeSpecifier.Performer:
- return TagPerformer;
- case ScopeSpecifier.Comment:
- return TagComment;
- case ScopeSpecifier.Disc:
- return TagDisc;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/LibMpc/Tags.cs b/LibMpc/Tags.cs
new file mode 100644
index 0000000..d367bd6
--- /dev/null
+++ b/LibMpc/Tags.cs
@@ -0,0 +1,34 @@
+namespace LibMpc
+{
+ public class Tags
+ {
+ internal class Tag : ITag
+ {
+ internal Tag(string value)
+ {
+ Value = value;
+ }
+
+ public string Value { get; }
+ }
+
+ public ITag Any { get; } = new Tag("any");
+ public ITag Filename { get; } = new Tag("filename");
+ public ITag Artist { get; }= new Tag("artist");
+ public ITag Album { get; }= new Tag("album");
+ public ITag Title { get; } = new Tag("title");
+ public ITag Track { get; } = new Tag("track");
+ public ITag Name { get; } = new Tag("name");
+ public ITag Genre { get; } = new Tag("genre");
+ public ITag Date { get; } = new Tag("date");
+ public ITag Composer { get; } = new Tag("composer");
+ public ITag Performer { get; } = new Tag("performer");
+ public ITag Comment { get; } = new Tag("comment");
+ public ITag Disc { get; } = new Tag("disc");
+ }
+
+ public interface ITag
+ {
+ string Value { get; }
+ }
+}
\ No newline at end of file