コード例 #1
0
 /// <summary>
 /// Shows the results.
 /// </summary>
 /// <param name="movie1">The movie1.</param>
 private void ShowResults(Movie movie1)
 {
     if (movie1.Title != null) TxtMovieTitle.Text = movie1.Title;
     var uri = new Uri(movie1.Cover.Cover, uriKind: UriKind.Absolute);
     ImgCover.Source = new BitmapImage(uri);
     if (movie1.Plot != null) BlockDescription.Text = movie1.Plot;
     if (movie1.Cover.Cover != null) urlImage = movie1.Cover.Cover;
     if (!string.IsNullOrWhiteSpace(movie1.RatingCount.ToString(CultureInfo.InvariantCulture)))
     {
         BlockRatingCounter.Text = movie1.RatingCount.ToString(CultureInfo.InvariantCulture);
     }
     if (movie1.Genres != null)
     {
         foreach (var genre in movie1.Genres)
         {
             BlockGenres.Text += genre + " ,";
         }
     }
     if (!string.IsNullOrWhiteSpace(movie1.Rated))
     {
         BlockRated.Text = movie1.Rated;
     }
     if (movie1.Language != null)
     {
         foreach (var language in movie1.Language)
         {
             BlockLanguage.Text += language + " ,";
         }
     }
     if (!string.IsNullOrWhiteSpace(movie1.Rating))
     {
         BlockRating.Text = movie1.Rating;
     }
     if (movie1.Country != null)
     {
         foreach (var country in movie1.Country)
         {
             BlockCountry.Text += country + " ,";
         }
     }
     if (!string.IsNullOrWhiteSpace(movie1.ReleaseDate))
     {
         var dateString = movie1.ReleaseDate.ToString(CultureInfo.InvariantCulture);
         var date = new DateTime(Convert.ToInt32(dateString.Substring(0, 4)),
             Convert.ToInt32(dateString.Substring(4, 2)), Convert.ToInt32(dateString.Substring(6, 2)));
         BlockReleaseDate.Text = date.Date.ToShortDateString();
     }
     if (!string.IsNullOrWhiteSpace(movie1.Year.ToString(CultureInfo.InvariantCulture)))
     {
         BlockYear.Text = movie1.Year.ToString(CultureInfo.InvariantCulture);
     }
     if (movie1.Directors != null)
     {
         foreach (var director in movie1.Directors)
         {
             BlockDirectors.Text += director + " ,";
         }
     }
     if (movie1.Actors != null)
     {
         foreach (var actor in movie1.Actors)
         {
             BlockActors.Text += actor + " ,";
         }
     }
     if (movie1.Runtime != null)
     {
         foreach (var runtime in movie1.Runtime)
         {
             BlockRuntime.Text += runtime + " ,";
         }
     }
     if (movie1.AltTitle != null)
     {
         foreach (var title in movie1.AltTitle)
         {
             BlockAltTitle.Text += title + " ,";
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Parses the response data.
 /// </summary>
 /// <param name="stringResponse">The string response.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 private void ParseResponseData(string stringResponse)
 {
     //TODO: The response comes into an array I need to create a task to do that
     movie = new Movie();
     stringResponse = stringResponse.Remove(0, 1);
     stringResponse = stringResponse.Remove(stringResponse.Length - 1, 1);
     var ms = new MemoryStream(Encoding.UTF8.GetBytes(stringResponse));
     var serialization = new DataContractJsonSerializer(movie.GetType());
     movie = serialization.ReadObject(ms) as Movie;
     ms.Close();
     if (movie != null)
     {
         ShowResults(movie);
     }
 }