示例#1
0
        /// <summary>
        /// Gets the artists by genre.
        /// </summary>
        /// <param name="genreId">The genre id.</param>
        /// <param name="musicSearchBy">The music search by.</param>
        /// <param name="marker">The next/previous marker to get next/previous items</param>
        /// <param name="locale">The locale.</param>
        /// <returns></returns>
        /// <exception cref="System.NullReferenceException">Genre Id cannot be null or empty</exception>
        public async Task <ArtistCollection> GetArtistsByGenreAsync(string genreId, MusicSearchBy musicSearchBy = MusicSearchBy.SalesRank, string marker = "afterMarker=CgAAAA%3d%3d", string locale = null)
        {
            if (string.IsNullOrEmpty(genreId))
            {
                throw new NullReferenceException("Genre Id cannot be null or empty");
            }

            locale = string.IsNullOrEmpty(locale) ? Locale : locale;

            var url = string.Format(Constants.ItemsByGenreUrlFormat, locale, genreId, "artists", musicSearchBy.ToString(), marker);

            var xml = await HttpClient.GetStringAsync(url);

            var result = ParseXml <ZuneArtistSearch.feed>(xml);

            if (result.entry == null)
            {
                return(new ArtistCollection(new List <Artist>()));
            }

            var resultList = new ArtistCollection(result.entry.Select(x => new Artist(x)).ToList());

            resultList.ProcessLinks(result.link);

            return(resultList);
        }