Exemple #1
0
        private static void ReceiveFriends(TwitterCursorList <TwitterUser> friends, TwitterResponse response, UserToken user)
        {
            if (friends == null || response.StatusCode != HttpStatusCode.OK)
            {
                return;
            }

            if (dicUsers.ContainsKey(user))
            {
                dicUsers[user] = dicUsers[user].Union(friends.Select(x => x.ScreenName)).ToList();
            }
            else
            {
                dicUsers[user] = friends.Select(x => x.ScreenName).ToList();
            }

            if (friends.NextCursor != null && friends.NextCursor != 0)
            {
                ServiceDispatcher.GetService(user).ListFriends(new ListFriendsOptions {
                    ScreenName = user.ScreenName, Cursor = (long)friends.NextCursor
                }, (l, r) => ReceiveFriends(l, r, user));
            }
            else
            {
                finishedUsers[user] = true;
                SaveUserCache(user, dicUsers[user]);
            }
        }
Exemple #2
0
        public void Load(bool Old = false)
        {
            if (service == null)
            {
                service = ServiceDispatcher.GetDefaultService();
            }

            if (Resource == null || service == null ||
                requestsInProgress >= 1 ||
                _rateResetTime > DateTime.Now)
            {
                if (LoadFinished != null)
                {
                    LoadFinished(this, new EventArgs());
                }
                return;
            }

            requestsInProgress++;

            if (Old)
            {
                LoadOld(lastId);
            }
            else
            {
                LoadNew();
            }
        }
Exemple #3
0
 public TweetLoader(TwitterResource resource, bool cached)
     : this()
 {
     Resource            = resource;
     service             = ServiceDispatcher.GetService(resource.User);
     conversationService = new ConversationService(resource.User);
     Cached = cached;
 }
Exemple #4
0
 private void GetService()
 {
     if (User == null)
     {
         _service = ServiceDispatcher.GetDefaultService();
     }
     else
     {
         _service = ServiceDispatcher.GetService(User);
     }
 }
Exemple #5
0
 public static void FillUserNames(IEnumerable <UserToken> users)
 {
     foreach (var user in users)
     {
         var temp = user;
         finishedUsers[temp] = false;
         dicUsers[temp]      = GetUserCache(temp).ToList();
         ServiceDispatcher.GetService(temp).ListFriends(new ListFriendsOptions {
             ScreenName = temp.ScreenName, Cursor = -1
         }, (list, response) => ReceiveFriends(list, response, temp));
     }
 }
Exemple #6
0
        public void FillUserData()
        {
            if (!(string.IsNullOrWhiteSpace(Token.ScreenName) || string.IsNullOrWhiteSpace(Token.AvatarUrl) || Token.Id == null))
            {
                return;
            }

            ITwitterService srv = ServiceDispatcher.GetService(Token);

            srv.GetUserProfile(new GetUserProfileOptions {
                IncludeEntities = true
            }, ReceiveUserProfile);
        }
Exemple #7
0
 public ConversationService(UserToken token)
 {
     service = ServiceDispatcher.GetService(token);
 }