using System.Collections.Generic;
using System.Xml;
using MusicMetaTagger.Client.AllMusicGuide.Properties;
using MusicMetaTagger.Core.Model;
using MusicMetaTagger.Core.Utility;

namespace MusicMetaTagger.Client.AllMusicGuide.RemoteDataAccess.Parser
{
	public class ArtistParser : ParserBase<Artist>
	{
		public override Artist Parse(XmlDocument artistXml)
		{
			var scraper = ArtistScaper.Default;
			var artist = new Artist();

			artist.ArtistId = StringUtility.CleanId(XpathMatchString(artistXml, scraper.ArtistIdXpath));
			artist.ArtistName = XpathMatchString(artistXml, scraper.ArtistXpath);

			if (XpathMatch(artistXml, scraper.GenreXpath))
				artist.Genre = XpathMatchString(artistXml, scraper.GenreXpath);

			artist.Styles =
				XpathMatch(artistXml, scraper.StylesXpath)
					? XpathMatchStringList(artistXml, scraper.StylesXpath)
					: new List<string>();

			return artist;
		}
	}
}