public void GetNextPageAsync() { if (HasMorePages) { var uri = new Uri(string.Format(SearchLinks.Next, Constants.ApiKey)); WebClient wc = new WebClient(); DownloadStringCompletedEventHandler f = null; f = (s, ea) => { wc.DownloadStringCompleted -= f; dynamic json = DynamicJsonObject.Parse(ea.Result); if (Movies == null) { Movies = new List <Movie>(); } foreach (var m in json.movies) { Movies.Add(new Movie(m, true)); } SearchLinks.Next = new SearchLinks(json.links, json.link_template).Next; ++currentPage; OnGetNextPageCompleted(); }; wc.DownloadStringCompleted += f; wc.DownloadStringAsync(uri); } else { OnGetNextPageCompleted(); } }
public void LoadDvdReviewsAsync() { if (HasMoreDvdReviews) { WebClient wc = new WebClient(); DownloadStringCompletedEventHandler f = null; f = (s, ea) => { wc.DownloadStringCompleted -= f; dynamic json = DynamicJsonObject.Parse(ea.Result); dvdReviewTotal = DynamicJsonObject.ParseIntFromDyn(json.total); if (DvdReviews == null) { DvdReviews = new List <Review>(); } foreach (var rev in json.reviews) { DvdReviews.Add(new Review(rev)); } OnLoadReviewsCompleted(); }; wc.DownloadStringCompleted += f; wc.DownloadStringAsync(new Uri(nextDvdReviewLink)); } else { OnLoadReviewsCompleted(); } }
private void Parse(string jsonString, int pageSize) { PageSize = pageSize; currentPage = 1; dynamic json = DynamicJsonObject.Parse(jsonString); Total = DynamicJsonObject.ParseIntFromDyn(json.total); Movies = new List <Movie>(); foreach (var m in json.movies) { Movies.Add(new Movie(m, true)); } SearchLinks = new SearchLinks(json.links, json.link_template); }
internal void GetMovieAsync(int id) { WebClient wc = new WebClient(); DownloadStringCompletedEventHandler f = null; f = (s, ea) => { wc.DownloadStringCompleted -= f; dynamic json = DynamicJsonObject.Parse(ea.Result); Parse(json); OnGetMovieMovieCompleted(); }; wc.DownloadStringCompleted += f; wc.DownloadStringAsync(new Uri(string.Format(Constants.MovieEndpoint, Constants.ApiKey, id))); }
public void LoadFullCastAsync() { WebClient wc = new WebClient(); DownloadStringCompletedEventHandler f = null; f = (s, ea) => { wc.DownloadStringCompleted -= f; dynamic json = DynamicJsonObject.Parse(ea.Result); FullCast = new List <CastMember>(); foreach (var cast in json.cast) { FullCast.Add(new CastMember(cast)); } OnLoadFullCastCompleted(); }; wc.DownloadStringCompleted += f; wc.DownloadStringAsync(new Uri(string.Format(Constants.CastEndpoint, Constants.ApiKey, Id))); }
internal void Parse(dynamic json, bool isAbbrev = false) { Id = DynamicJsonObject.ParseIntFromDyn(json.id); Title = json.title; Year = DynamicJsonObject.ParseIntFromDyn(json.year); if (isAbbrev) { Genres = null; AbridgedDirectors = null; } else { Genres = new List <string>(); foreach (var g in json.genres) { Genres.Add(g); } if (json.abridged_directors == null) { AbridgedDirectors = null; } else { AbridgedDirectors = new List <string>(); foreach (var ad in json.abridged_directors) { AbridgedDirectors.Add(ad.name); } } } MPAARating = json.mpaa_rating; Runtime = DynamicJsonObject.ParseIntFromDyn(json.runtime); ReleaseDates = new ReleaseDates(json.release_dates); Ratings = new Ratings(json.ratings); Synopsis = json.synopsis; Posters = new Posters(json.posters); AbridgedCast = new List <CastMember>(); foreach (var ac in json.abridged_cast) { AbridgedCast.Add(new CastMember(ac)); } Links = new MovieLinks(json.links); IsAbridged = isAbbrev; }