Exemplo n.º 1
0
        private void ProcessIncomingTweets(TwitterResponse response, IEnumerable<TwitterStatus> statuses, Dispatcher dispatcher)
        {
            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception(response.StatusCode.ToString());
            }

            foreach (var status in statuses)
            {
                var inline = status;
                var tweet = new Tweet(inline);

                dispatcher.BeginInvoke(() => _tweets.Items.Add(tweet));
            }
        }
Exemplo n.º 2
0
        private void FluentExample(Dispatcher dispatcher)
        {
            FluentTwitter.CreateRequest()
                .Statuses().OnPublicTimeline().AsJson()
                .BeginRequest((statuses, response) =>
                                  {
                                      if (response.StatusCode == HttpStatusCode.OK)
                                      {
                                          ProcessIncomingTweets(response, statuses, dispatcher);
                                      }
                                  });

            FluentTwitter.CreateRequest()
                .Statuses().Update(DateTime.Now.Ticks.ToString())
                .BeginRequest((status, response) =>
                                  {
                                      if (response.StatusCode != HttpStatusCode.OK)
                                      {
                                          return;
                                      }
                                      var tweet = new Tweet(status);
                                      dispatcher.BeginInvoke(() => _tweets.Items.Add(tweet));
                                  });
        }