コード例 #1
0
 public static Movie ConvertToMovie(OmdbMovie omdbMovie)
 {
     return(new Movie
     {
         Title = omdbMovie.Title,
         Plot = omdbMovie.Plot,
         Awards = omdbMovie.Awards,
         PosterUrl = omdbMovie.Poster,
         ImdbId = omdbMovie.ImdbId,
         Type = omdbMovie.Type,
         Dvd = omdbMovie.Dvd,
         BoxOffice = omdbMovie.BoxOffice,
         Production = omdbMovie.Production,
         WebsiteUrl = omdbMovie.Website,
         Rated = omdbMovie.Rated,
         Year = GetYear(omdbMovie.Year),
         Actors = GetPersons <Actor>(omdbMovie.Actors),
         Writers = GetPersons <Writer>(omdbMovie.Writer),
         Directors = GetPersons <Director>(omdbMovie.Director),
         Genres = GetStrings(omdbMovie.Genre),
         Countries = GetStrings(omdbMovie.Country),
         Languages = GetStrings(omdbMovie.Language),
         Runtime = GetRuntime(omdbMovie.Runtime),
         ImdbRating = GetImdbRating(omdbMovie.ImdbRating),
         ImdbVotes = GetImdbVotes(omdbMovie.ImdbVotes),
         Metascore = GetMetascore(omdbMovie.Metascore),
         ReleasedAt = GetReleasedAt(omdbMovie.Released),
         Ratings = GetRatings(omdbMovie.Ratings),
     });
 }
コード例 #2
0
        private async Task <OmdbMovie> GetMovieFromResponseAsync(HttpResponseMessage response)
        {
            OmdbMovie movie = null;
            string    json  = await response.Content.ReadAsStringAsync();

            try
            {
                movie = JsonSerializer.Deserialize <OmdbMovie>(json);
            }
            catch (Exception e)
            {
                throw;
            }

            return(movie);
        }