コード例 #1
0
ファイル: ReviewsTests.cs プロジェクト: softica/wp7rt-client
 public void CheckIntialValues()
 {
     wp7rt_client.Classes.Review review = new wp7rt_client.Classes.Review();
     Assert.Equals(review.AbsoluteLink, "");
     Assert.Equals(review.OrgScore, "NA");
     Assert.IsNotNull(review.Links);
 }
コード例 #2
0
ファイル: Parser.cs プロジェクト: softica/wp7rt-client
        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;
        }