MapFrom() public méthode

Map from LastFmClient.
public MapFrom ( LastFm image ) : void
image LastFm An image.
Résultat void
Exemple #1
0
        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;
        }
Exemple #2
0
 public void MapFrom(SimilarArtist artist)
 {
     this.Name = artist.Name;
     this.Url = artist.Url;
     this.Images = new List<Image>();
     foreach (var image in artist.Image)
     {
         var artistImage = new Image();
         artistImage.MapFrom(image);
         this.Images.Add(artistImage);
     }
 }
Exemple #3
0
 public void MapFrom(SimilarArtist artist)
 {
     this.Name   = artist.Name;
     this.Url    = artist.Url;
     this.Images = new List <Image>();
     foreach (var image in artist.Image)
     {
         var artistImage = new Image();
         artistImage.MapFrom(image);
         this.Images.Add(artistImage);
     }
 }
Exemple #4
0
        public void MapFrom(TopAlbum topAlbum)
        {
            this.Name = topAlbum.Name;
            this.Url = topAlbum.Url;
            this.Playcount = Convert.ToInt64(topAlbum.Playcount);

            var artist = new Artist();
            artist.MapFrom(topAlbum.Artist);
            this.Artist = artist;
            this.Images = new List<Image>();
            foreach (var image in topAlbum.Image)
            {
                var artistImage = new Image();
                artistImage.MapFrom(image);
                this.Images.Add(artistImage);
            }
        }
Exemple #5
0
        public void MapFrom(TopAlbum topAlbum)
        {
            this.Name      = topAlbum.Name;
            this.Url       = topAlbum.Url;
            this.Playcount = Convert.ToInt64(topAlbum.Playcount);

            var artist = new Artist();

            artist.MapFrom(topAlbum.Artist);
            this.Artist = artist;
            this.Images = new List <Image>();
            foreach (var image in topAlbum.Image)
            {
                var artistImage = new Image();
                artistImage.MapFrom(image);
                this.Images.Add(artistImage);
            }
        }
Exemple #6
0
        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;
        }