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();
     }
 }
Esempio n. 2
0
 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);
        }
Esempio n. 4
0
        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)));
        }
Esempio n. 5
0
        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)));
        }