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

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

            if (cursor == 0)
            {
                FollowerIds = new List <long>();
                Followers   = new List <IUser>();
            }

            string query = Resources.User_GetFollowers;

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

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

                if (userIds != null)
                {
                    foreach (var followerId in userIds)
                    {
                        FollowerIds.Add(Int64.Parse(followerId.ToString()));

                        if (createFollowerList)
                        {
                            Followers.Add(new User(Int64.Parse(followerId.ToString()))
                            {
                                ObjectToken = _shareTokenWithChild ? _token : null,
                            });
                        }
                    }

                    return(userIds.Count());
                }

                return(0);
            };

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

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

            if (cursor == 0)
            {
                FollowerIds = new List <long>();
                Followers   = new List <IUser>();
            }

            string query = Resources.User_GetFollowers;

            AddUserInformationInQuery(ref query);

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

                    if (createFollowerList)
                    {
                        Followers.Add(new User((long)follower_id)
                        {
                            ObjectToken = _shareTokenWithChild ? this._token : null,
                        });
                    }
                }
            };

            token.ExecuteCursorQuery(query, del);

            return(FollowerIds);
        }