Esempio n. 1
0
        private void ReceiveTrends(TweetSharp.TwitterTrends Trends, TweetSharp.TwitterResponse Response)
        {
            IsLoading = false;
            if (Response.StatusCode != HttpStatusCode.OK)
            {
                MessageService.ShowError(Localization.Resources.ErrorLoadingTT);
                GoBack();
            }

            Collection = Trends;
        }
        private object DeserializeTrends(string content)
        {
            // --> Current model is not quite right
            // "[{\"trends\":[{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=%23WaysToMakeMeMad\",\"name\":\"#WaysToMakeMeMad\",\"events\":null,\"query\":\"%23WaysToMakeMeMad\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=%23ThoughtsInClass\",\"name\":\"#ThoughtsInClass\",\"events\":null,\"query\":\"%23ThoughtsInClass\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=%23ScarlettHeightsProblems\",\"name\":\"#ScarlettHeightsProblems\",\"events\":null,\"query\":\"%23ScarlettHeightsProblems\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=%22Isaiah%20Thomas%22\",\"name\":\"Isaiah Thomas\",\"events\":null,\"query\":\"%22Isaiah%20Thomas%22\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=OCAP\",\"name\":\"OCAP\",\"events\":null,\"query\":\"OCAP\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=%22Henrik%20Sedin%22\",\"name\":\"Henrik Sedin\",\"events\":null,\"query\":\"%22Henrik%20Sedin%22\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=Russia\",\"name\":\"Russia\",\"events\":null,\"query\":\"Russia\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=%22Kenneth%20Faried%22\",\"name\":\"Kenneth Faried\",\"events\":null,\"query\":\"%22Kenneth%20Faried%22\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=%22Kyrie%20Irving%22\",\"name\":\"Kyrie Irving\",\"events\":null,\"query\":\"%22Kyrie%20Irving%22\"},{\"promoted_content\":null,\"url\":\"http:\\/\\/twitter.com\\/search?q=%23iWontReplyIf\",\"name\":\"#iWontReplyIf\",\"events\":null,\"query\":\"%23iWontReplyIf\"}],\"locations\":[{\"name\":\"Toronto\",\"woeid\":4118}],\"as_of\":\"2013-02-16T05:58:55Z\",\"created_at\":\"2013-02-16T05:56:01Z\"}]"
            var collection = JArray.Parse(content);
            var result     = new TwitterTrends {
                RawSource = content
            };

            foreach (var item in collection)
            {
                var inner = item["trends"];
                if (inner != null)
                {
                    var trends = (DeserializeCollection(inner.ToString(), typeof(IEnumerable <TwitterTrend>)) as IEnumerable <TwitterTrend>).ToList();
                    result.Trends.AddRange(trends);
                }
            }
            return(result);
        }