VLC_WINRT.Utility.Helpers.MusicLibrary.MusicEntities.Artist.MapFrom C# (CSharp) Method

MapFrom() public method

public MapFrom ( ArtistInformation artistInformation ) : void
artistInformation VLC_WINRT.Utility.Helpers.MusicLibrary.LastFm.ArtistInformation
return void
        public void MapFrom(ArtistInformation artistInformation)
        {
            var artist = artistInformation.Artist;
            this.Name = artist.Name;
            this.Url = Url;

            // I hope this is not stupid code. It broke on Boolean.Parse :(.
            switch (artist.Ontour)
            {
                case "0":
                    this.OnTour = false;
                    break;
                case "1":
                    this.OnTour = true;
                    break;
                default:
                    this.OnTour = false;
                    break;
            }

            this.Images = new List<Image>();
            foreach (var image in artist.Image)
            {
                var artistImage = new Image();
                artistImage.MapFrom(image);
                this.Images.Add(artistImage);
            }

            this.Playcount = Convert.ToInt64(this.Playcount);
            this.Listeners = Convert.ToInt64(this.Listeners);
            string biography;

            var resourceLoader = new ResourceLoader();
            var bioSummary = artist.Bio.Summary;
            if (bioSummary != null)
            {
                // Deleting the html tags
                biography = Regex.Replace(bioSummary, "<.*?>", string.Empty);
                // Remove leading new lines.
                biography = biography.TrimStart('\r', '\n');
                // Remove leading and ending white spaces.
                biography = biography.Trim();
                // TODO: Replace string "remove" with something better. It may not work on all artists and in all languages.
                biography = !string.IsNullOrEmpty(biography) ? biography.Remove(biography.Length - "Read more about  on Last.fm".Length - artist.Name.Length - 6)
                    : resourceLoader.GetString("NoBiographyFound");
            }
            else
            {
                biography = resourceLoader.GetString("NoBiographyFound");
            }
            this.Biography = biography;
        }

Same methods

Artist::MapFrom ( Deezer deezerArtist ) : void
Artist::MapFrom ( SimilarArtist artist ) : void
Artist::MapFrom ( TopArtist artist ) : void
Artist::MapFrom ( XboxMusicLibrary xboxArtistItem ) : void

Usage Example

Example #1
0
 public async Task<List<Artist>> GetSimilarArtists(string artistId)
 {
     var deezerClient = new HttpClient();
     string json = await deezerClient.GetStringAsync(string.Format("http://api.deezer.com/artist/{0}/related", artistId));
     var deezerArtists = JsonConvert.DeserializeObject<Artists>(json);
     var artistList = new List<Artist>();
     foreach (var deezerArtist in deezerArtists.Data)
     {
         var artist = new Artist();
         artist.MapFrom(deezerArtist);
         artistList.Add(artist);
     }
     return artistList;
 }
All Usage Examples Of VLC_WINRT.Utility.Helpers.MusicLibrary.MusicEntities.Artist::MapFrom
Artist