public BenchmarkContainer() { var json = File.ReadAllText("spotifyAlbum.json"); _spotifyAlbumDto = SpotifyAlbumDto.FromJson(json); //Console.WriteLine(JsonConvert.SerializeObject(_spotifyAlbumDto)); //Automapper Configuration var mapperConfig = new MapperConfiguration(cfg => { cfg.CreateMap <SpotifyAlbumDto, SpotifyAlbum>(); cfg.CreateMap <CopyrightDto, Copyright>(); cfg.CreateMap <ArtistDto, Artist>(); cfg.CreateMap <ExternalIdsDto, ExternalIds>(); cfg.CreateMap <ExternalUrlsDto, ExternalUrls>(); cfg.CreateMap <TracksDto, Tracks>(); cfg.CreateMap <ImageDto, Image>(); cfg.CreateMap <ItemDto, Item>(); cfg.CreateMap <SpotifyAlbum, SpotifyAlbumDto>(); cfg.CreateMap <Copyright, CopyrightDto>(); cfg.CreateMap <Artist, ArtistDto>(); cfg.CreateMap <ExternalIds, ExternalIdsDto>(); cfg.CreateMap <ExternalUrls, ExternalUrlsDto>(); cfg.CreateMap <Tracks, TracksDto>(); cfg.CreateMap <Image, ImageDto>(); cfg.CreateMap <Item, ItemDto>(); }); _autoMapper = mapperConfig.CreateMapper(); //TinyMapper Configuration TinyMapper.Bind <SpotifyAlbumDto, SpotifyAlbum>(); TinyMapper.Bind <CopyrightDto, Copyright>(); TinyMapper.Bind <ArtistDto, Artist>(); TinyMapper.Bind <ExternalIdsDto, ExternalIds>(); TinyMapper.Bind <ExternalUrlsDto, ExternalUrls>(); TinyMapper.Bind <TracksDto, Tracks>(); TinyMapper.Bind <ImageDto, Image>(); TinyMapper.Bind <ItemDto, Item>(); TinyMapper.Bind <SpotifyAlbum, SpotifyAlbumDto>(); TinyMapper.Bind <Copyright, CopyrightDto>(); TinyMapper.Bind <Artist, ArtistDto>(); TinyMapper.Bind <ExternalIds, ExternalIdsDto>(); TinyMapper.Bind <ExternalUrls, ExternalUrlsDto>(); TinyMapper.Bind <Tracks, TracksDto>(); TinyMapper.Bind <Image, ImageDto>(); TinyMapper.Bind <Item, ItemDto>(); }
public static SpotifyAlbum Map(this SpotifyAlbumDto spotifyAlbumDto) { return(new SpotifyAlbum() { AlbumType = spotifyAlbumDto.AlbumType, Artists = spotifyAlbumDto.Artists.Select(spotifyAlbumDtoArtist => new Artist() { ExternalUrls = new ExternalUrls() { Spotify = spotifyAlbumDtoArtist.ExternalUrls.Spotify }, Href = spotifyAlbumDtoArtist.Href, Id = spotifyAlbumDtoArtist.Id, Name = spotifyAlbumDtoArtist.Name, Type = spotifyAlbumDtoArtist.Type, Uri = spotifyAlbumDtoArtist.Uri }).ToArray(), AvailableMarkets = spotifyAlbumDto.AvailableMarkets, Copyrights = spotifyAlbumDto.Copyrights.Select(spotifyAlbumDtoCopyright => new Copyright() { Text = spotifyAlbumDtoCopyright.Text, Type = spotifyAlbumDtoCopyright.Type }).ToArray(), ExternalIds = new ExternalIds() { Upc = spotifyAlbumDto.ExternalIds.Upc }, ExternalUrls = new ExternalUrls() { Spotify = spotifyAlbumDto.ExternalUrls.Spotify }, Genres = spotifyAlbumDto.Genres, Href = spotifyAlbumDto.Href, Id = spotifyAlbumDto.Id, Images = spotifyAlbumDto.Images.Select(spotifyAlbumDtoImage => new Image() { Height = spotifyAlbumDtoImage.Height, Url = spotifyAlbumDtoImage.Url, Width = spotifyAlbumDtoImage.Width }).ToArray(), Name = spotifyAlbumDto.Name, Popularity = spotifyAlbumDto.Popularity, ReleaseDate = spotifyAlbumDto.ReleaseDate, ReleaseDatePrecision = spotifyAlbumDto.ReleaseDatePrecision, Tracks = new Tracks() { Href = spotifyAlbumDto.Tracks.Href, Items = spotifyAlbumDto.Tracks.Items.Select(spotifyAlbumDtoTracksItem => new Item() { Artists = spotifyAlbumDtoTracksItem.Artists.Select(spotifyAlbumDtoTracksItemArtist => new Artist() { ExternalUrls = new ExternalUrls() { Spotify = spotifyAlbumDtoTracksItemArtist.ExternalUrls.Spotify }, Href = spotifyAlbumDtoTracksItemArtist.Href, Id = spotifyAlbumDtoTracksItemArtist.Id, Name = spotifyAlbumDtoTracksItemArtist.Name, Type = spotifyAlbumDtoTracksItemArtist.Type, Uri = spotifyAlbumDtoTracksItemArtist.Uri }).ToArray(), AvailableMarkets = spotifyAlbumDtoTracksItem.AvailableMarkets, DiscNumber = spotifyAlbumDtoTracksItem.DiscNumber, DurationMs = spotifyAlbumDtoTracksItem.DurationMs, Explicit = spotifyAlbumDtoTracksItem.Explicit, ExternalUrls = new ExternalUrls() { Spotify = spotifyAlbumDtoTracksItem.ExternalUrls.Spotify }, Href = spotifyAlbumDtoTracksItem.Href, Id = spotifyAlbumDtoTracksItem.Id, Name = spotifyAlbumDtoTracksItem.Name, PreviewUrl = spotifyAlbumDtoTracksItem.PreviewUrl, TrackNumber = spotifyAlbumDtoTracksItem.TrackNumber, Type = spotifyAlbumDtoTracksItem.Type, Uri = spotifyAlbumDtoTracksItem.Uri }).ToArray(), Limit = spotifyAlbumDto.Tracks.Limit, Next = spotifyAlbumDto.Tracks.Next, Offset = spotifyAlbumDto.Tracks.Offset, Previous = spotifyAlbumDto.Tracks.Previous, Total = spotifyAlbumDto.Tracks.Total }, Type = spotifyAlbumDto.Type, Uri = spotifyAlbumDto.Uri }); }
public BenchmarkContainer() { var json = File.ReadAllText("spotifyAlbum.json"); _spotifyAlbumDto = SpotifyAlbumDto.FromJson(json); //Automapper Configuration var mapperConfig = new MapperConfiguration(cfg => { cfg.CreateMap <SpotifyAlbumDto, SpotifyAlbum>(); cfg.CreateMap <CopyrightDto, Copyright>(); cfg.CreateMap <ArtistDto, Artist>(); cfg.CreateMap <ExternalIdsDto, ExternalIds>(); cfg.CreateMap <ExternalUrlsDto, ExternalUrls>(); cfg.CreateMap <TracksDto, Tracks>(); cfg.CreateMap <ImageDto, Image>(); cfg.CreateMap <ItemDto, Item>(); cfg.CreateMap <SpotifyAlbum, SpotifyAlbumDto>(); cfg.CreateMap <Copyright, CopyrightDto>(); cfg.CreateMap <Artist, ArtistDto>(); cfg.CreateMap <ExternalIds, ExternalIdsDto>(); cfg.CreateMap <ExternalUrls, ExternalUrlsDto>(); cfg.CreateMap <Tracks, TracksDto>(); cfg.CreateMap <Image, ImageDto>(); cfg.CreateMap <Item, ItemDto>(); }); _autoMapper = mapperConfig.CreateMapper(); //TinyMapper Configuration Nelibur.ObjectMapper.TinyMapper.Bind <SpotifyAlbumDto, SpotifyAlbum>(); Nelibur.ObjectMapper.TinyMapper.Bind <CopyrightDto, Copyright>(); Nelibur.ObjectMapper.TinyMapper.Bind <ArtistDto, Artist>(); Nelibur.ObjectMapper.TinyMapper.Bind <ExternalIdsDto, ExternalIds>(); Nelibur.ObjectMapper.TinyMapper.Bind <ExternalUrlsDto, ExternalUrls>(); Nelibur.ObjectMapper.TinyMapper.Bind <TracksDto, Tracks>(); Nelibur.ObjectMapper.TinyMapper.Bind <ImageDto, Image>(); Nelibur.ObjectMapper.TinyMapper.Bind <ItemDto, Item>(); Nelibur.ObjectMapper.TinyMapper.Bind <SpotifyAlbum, SpotifyAlbumDto>(); Nelibur.ObjectMapper.TinyMapper.Bind <Copyright, CopyrightDto>(); Nelibur.ObjectMapper.TinyMapper.Bind <Artist, ArtistDto>(); Nelibur.ObjectMapper.TinyMapper.Bind <ExternalIds, ExternalIdsDto>(); Nelibur.ObjectMapper.TinyMapper.Bind <ExternalUrls, ExternalUrlsDto>(); Nelibur.ObjectMapper.TinyMapper.Bind <Tracks, TracksDto>(); Nelibur.ObjectMapper.TinyMapper.Bind <Image, ImageDto>(); Nelibur.ObjectMapper.TinyMapper.Bind <Item, ItemDto>(); //ExpressMapper Configuration global::ExpressMapper.Mapper.Register <SpotifyAlbumDto, SpotifyAlbum>(); global::ExpressMapper.Mapper.Register <CopyrightDto, Copyright>(); global::ExpressMapper.Mapper.Register <ArtistDto, Artist>(); global::ExpressMapper.Mapper.Register <ExternalIdsDto, ExternalIds>(); global::ExpressMapper.Mapper.Register <ExternalUrlsDto, ExternalUrls>(); global::ExpressMapper.Mapper.Register <TracksDto, Tracks>(); global::ExpressMapper.Mapper.Register <ImageDto, Image>(); global::ExpressMapper.Mapper.Register <ItemDto, Item>(); global::ExpressMapper.Mapper.Register <SpotifyAlbum, SpotifyAlbumDto>(); global::ExpressMapper.Mapper.Register <Copyright, CopyrightDto>(); global::ExpressMapper.Mapper.Register <Artist, ArtistDto>(); global::ExpressMapper.Mapper.Register <ExternalIds, ExternalIdsDto>(); global::ExpressMapper.Mapper.Register <ExternalUrls, ExternalUrlsDto>(); global::ExpressMapper.Mapper.Register <Tracks, TracksDto>(); global::ExpressMapper.Mapper.Register <Image, ImageDto>(); global::ExpressMapper.Mapper.Register <Item, ItemDto>(); //Mapster don't need configuration //AgileMapper don't need configuration }
public static string ToJson(this SpotifyAlbumDto self) { return(JsonConvert.SerializeObject(self, Converter.Settings)); }