示例#1
0
        private static MovieClips ParseMovieClips(JToken jToken)
        {
            MovieClips ListOfClips = new MovieClips();

            var jsonArray = (JArray)jToken;

            if (jsonArray == null)
                return ListOfClips;

            foreach (var clip in jsonArray)
            {
                Clip newClip = new Clip();

                newClip.Title = (string)clip["title"];
                newClip.Duration = (string)clip["duration"];
                newClip.Thumbnail = (string)clip["thumbnail"];                

                var links = (JObject)clip["links"];

                if (links != null)
                {
                    foreach (var link in links)
                    {                           
                        Link newLink = new Link { Type = (string)link.Key, Url = (string)link.Value };
                        if ((string)link.Key == "alternate")
                        {
                            newClip.AbsoluteLink = (string)link.Value;
                        }
                        newClip.Links.Add(newLink);                        
                    }
                }

                if (newClip.Duration != "-1")
                {
                    ListOfClips.Clips.Add(newClip);
                }
            }

            return ListOfClips;
        }
示例#2
0
        private static Reviews ParseMovieReviews(JToken jToken)
        {            
            Reviews MovieReviews = new Reviews();

            var jsonArray = (JArray)jToken;

            if (jsonArray == null)
                return MovieReviews;

            foreach (var review in jsonArray)
            {
                Review newReview = new Review();

                newReview.Critic = (string)review["critic"];
                newReview.Date = (string)review["date"];
                newReview.Freshness = (string)review["freshness"];
                newReview.Publication = (string)review["publication"];
                newReview.Quote = (string)review["quote"];

                if ((string)review["original_score"] != null) { newReview.OrgScore = (string)review["original_score"]; }               
                
                var links = (JObject)review["links"];

                if (links != null)
                {
                    foreach (var link in links)
                    {
                        Link newLink = new Link { Type = (string)link.Key, Url = (string)link.Value };
                        if ((string)link.Key == "review")
                        {
                            newReview.AbsoluteLink = (string)link.Value;
                        }
                        newReview.Links.Add(newLink);
                    }
                }

                MovieReviews.MovieReviews.Add(newReview);
            }

            return MovieReviews;
        }
示例#3
0
        private static List<Link> ParseLinks(JToken jToken)
        {
            List<Link> links = new List<Link>();
            var jsonArray = (JObject)jToken;

            if (jsonArray == null)
                return links;

            foreach (var link in jsonArray)
            {
                Link newLink = new Link { Type = (string)link.Key, Url = (string)link.Value };
                links.Add(newLink);
            }

            return links;
        }