using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Hqub.MusicBrainz.API.Entities.Collections;
using Hqub.MusicBrainz.API.Entities.Metadata;
namespace Hqub.MusicBrainz.API.Entities
{
[XmlRoot("release", Namespace = "http://musicbrainz.org/ns/mmd-2.0#")]
public class Release : Entity
{
public const string EntityName = "release";
#region Properties
///
/// Gets or sets the score (only available in search results).
///
[XmlAttribute("score", Namespace = "http://musicbrainz.org/ns/ext#-2.0")]
public int Score { get; set; }
///
/// Gets or sets the MusicBrainz id.
///
[XmlAttribute("id")]
public string Id { get; set; }
///
/// Gets or sets the title.
///
[XmlElement("title")]
public string Title { get; set; }
///
/// Gets or sets the status.
///
[XmlElement("status")]
public string Status { get; set; }
///
/// Gets or sets the quality.
///
[XmlElement("quality")]
public string Quality { get; set; }
///
/// Gets or sets the text-representation.
///
[XmlElement("text-representation")]
public TextRepresentation TextRepresentation { get; set; }
///
/// Gets or sets the date.
///
[XmlElement("date")]
public string Date { get; set; }
///
/// Gets or sets the country.
///
[XmlElement("country")]
public string Country { get; set; }
///
/// Gets or sets the barcode.
///
[XmlElement("barcode")]
public string Barcode { get; set; }
///
/// Gets or sets the release-group.
///
[XmlElement("release-group")]
public ReleaseGroup ReleaseGroup { get; set; }
///
/// Gets or sets the cover-art-archive.
///
[XmlElement("cover-art-archive")]
public CoverArtArchive CoverArtArchive { get; set; }
#endregion
#region Subqueries
[XmlArray("artist-credit")]
[XmlArrayItem("name-credit")]
public List Credits { get; set; }
[XmlArray("label-info-list")]
[XmlArrayItem("label-info")]
public List Labels { get; set; }
[XmlElement("medium-list")]
public Collections.MediumList MediumList { get; set; }
#endregion
#region Static Methods
[Obsolete("Use GetAsync() method.")]
public static Release Get(string id, params string[] inc)
{
return GetAsync(EntityName, id, inc).Result;
}
[Obsolete("Use SearchAsync() method.")]
public static ReleaseList Search(string query, int limit = 25, int offset = 0)
{
return SearchAsync(EntityName,
query, limit, offset).Result.Collection;
}
///
/// Lookup a release in the MusicBrainz database.
///
/// The release MusicBrainz id.
/// A list of entities to include (subqueries).
///
public async static Task GetAsync(string id, params string[] inc)
{
return await GetAsync(EntityName, id, inc);
}
///
/// Search for a release in the MusicBrainz database, matching the given query.
///
/// The query string.
/// The maximum number of releases to return (default = 25).
/// The offset to the releases list (enables paging, default = 0).
///
public async static Task SearchAsync(string query, int limit = 25, int offset = 0)
{
return (await SearchAsync(EntityName,
query, limit, offset)).Collection;
}
///
/// Search for a release in the MusicBrainz database, matching the given query.
///
/// The query parameters.
/// The maximum number of releases to return (default = 25).
/// The offset to the releases list (enables paging, default = 0).
///
public async static Task SearchAsync(QueryParameters query, int limit = 25, int offset = 0)
{
return (await SearchAsync(EntityName,
query.ToString(), limit, offset)).Collection;
}
///
/// Browse all the releases in the MusicBrainz database, which are directly linked to the
/// entity with given id.
///
/// The name of the related entity.
/// The id of the related entity.
/// The maximum number of releases to return (default = 25).
/// The offset to the releases list (enables paging, default = 0).
/// A list of entities to include (subqueries).
///
public static async Task BrowseAsync(string entity, string id, int limit = 25,
int offset = 0, params string[] inc)
{
return (await BrowseAsync(EntityName,
entity, id, limit, offset, inc)).Collection;
}
#endregion
}
[XmlType(Namespace = "http://musicbrainz.org/ns/mmd-2.0#")]
[XmlRoot("text-representation", Namespace = "http://musicbrainz.org/ns/mmd-2.0#")]
public class TextRepresentation
{
///
/// Gets or sets the language.
///
[XmlElement("language")]
public string Language { get; set; }
///
/// Gets or sets the script.
///
[XmlElement("script")]
public string Script { get; set; }
}
}