예제 #1
0
        /// <summary>
        /// Get a List of Friends Ids by using the Current Token
        /// </summary>
        /// <param name="token">Token to operate the query</param>
        /// <param name="createUserIdsList">Whether this method will fill the Friends list</param>
        /// <param name="cursor">Current Page of the query</param>
        /// <param name="maxFriends">Max number of users</param>
        /// <returns>List of Friends Id</returns>
        public List <long> GetFriendIds(IToken token, bool createUserIdsList = false, long cursor = 0, int maxFriends = Int32.MaxValue)
        {
            token = GetQueryToken(token);

            if (token == null)
            {
                return(null);
            }

            if (cursor == 0)
            {
                FriendIds = new List <long>();
                Friends   = new List <IUser>();
            }

            DynamicResponseDelegate del = delegate(Dictionary <string, object> responseObject, long previousCursor, long nextCursor)
            {
                var userFriendIds = (responseObject["ids"] as IEnumerable <object>) != null ? (responseObject["ids"] as IEnumerable <object>).ToList() : null;

                if (userFriendIds != null)
                {
                    foreach (var friendId in userFriendIds)
                    {
                        FriendIds.Add(Int64.Parse(friendId.ToString()));

                        if (createUserIdsList)
                        {
                            Friends.Add(new User(Int64.Parse(friendId.ToString()))
                            {
                                ObjectToken = _shareTokenWithChild ? this._token : null,
                            });
                        }
                    }

                    return(userFriendIds.Count());
                }

                return(0);
            };

            string query = Resources.User_GetFriends;

            if (!AddUserInformationInQuery(ref query))
            {
                return(null);
            }

            token.ExecuteCursorQuery(query, 0, maxFriends, del);
            return(FriendIds);
        }
예제 #2
0
파일: User.cs 프로젝트: twdean/MeleeMe
        /// <summary>
        /// Get a List of Friends Ids by using the Current Token
        /// </summary>
        /// <param name="token">Token to operate the query</param>
        /// <param name="createUserIdsList">Whether this method will fill the Friends list</param>
        /// <param name="cursor">Current Page of the query</param>
        /// <returns>List of Friends Id</returns>
        public List <long> GetFriendsIds(IToken token, bool createUserIdsList = false, long cursor = 0)
        {
            token = GetQueryToken(token);

            if (token == null)
            {
                return(null);
            }

            if (cursor == 0)
            {
                FriendIds = new List <long>();
                Friends   = new List <IUser>();
            }

            DynamicResponseDelegate del = delegate(dynamic responseObject, long previous_cursor, long next_cursor)
            {
                foreach (var friend_id in responseObject["ids"])
                {
                    FriendIds.Add((long)friend_id);

                    if (createUserIdsList)
                    {
                        Friends.Add(new User((long)friend_id)
                        {
                            ObjectToken = _shareTokenWithChild ? this._token : null,
                        });
                    }
                }
            };

            if (Id != null)
            {
                token.ExecuteCursorQuery(String.Format(Resources.User_GetFriendsIdsFromId, Id), del);
            }
            else
            {
                if (_screen_name != null)
                {
                    token.ExecuteCursorQuery(String.Format(Resources.User_GetFriendsIdsFromScreenName, ScreenName), del);
                }
            }

            return(FriendIds);
        }