예제 #1
0
        public async override Task <Photo> GetRandomPhotoAsync(int width, int height)
        {
            string url = string.Format("{0}{1}?w={2}&h={3}", ApiRoot, RandomPhotoEndpoint, width, height);

            using (Stream data = await this.httpService.GetAsync(url))
            {
                UnsplashPhoto unsplashPhoto = this.deserialiser.DeserialiseTo <UnsplashPhoto>(data);
                return(MapToPhoto(unsplashPhoto));
            }
        }
예제 #2
0
        private Photo MapToPhoto(UnsplashPhoto unsplashPhoto)
        {
            return(new Photo
            {
                Url = unsplashPhoto.PhotoCollection.Custom,

                User = new User
                {
                    Name = unsplashPhoto.User.Name,
                    Avatar = unsplashPhoto.User.AvatarCollection.Medium
                },

                Location = new Location
                {
                    City = unsplashPhoto.Location?.City,
                    Country = unsplashPhoto.Location?.Country
                }
            });
        }