예제 #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);
        }
예제 #3
0
        /// <inheritdoc />
        /// <summary>
        /// Returns true if MeetupDraftProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of MeetupDraftProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(MeetupDraftProperties other)
        {
#pragma warning disable IDE0041 // Use 'is null' check
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

#pragma warning disable CA1309                  // Use ordinal stringcomparison
#pragma warning disable CA1307                  // Specify StringComparison
#pragma warning disable SA1515                  // Single-line comment must be preceded by blank line
#pragma warning disable SA1009                  // Closing parenthesis must be spaced correctly
            return
                (#pragma warning disable SA1119 // Statement must not use unnecessary parenthesis
                 (
                     // ReSharper disable once RedundantNameQualifier
                     string.Equals(Name, other.Name) ||
                     (Name != null && Name.Equals(other.Name))
                 ) &&
                 (
                     // ReSharper disable once RedundantNameQualifier
                     string.Equals(VenueId, other.VenueId) ||
                     (VenueId != null && VenueId.Equals(other.VenueId))
                 ) &&
                 (
                     FriendIds == other.FriendIds ||
                     (FriendIds != null && FriendIds.SequenceEqual(other.FriendIds))
                 ) &&
                 (
                     TalkDraftIds == other.TalkDraftIds ||
                     (TalkDraftIds != null && TalkDraftIds.SequenceEqual(other.TalkDraftIds))
                 ));

#pragma warning restore SA1119 // Statement must not use unnecessary parenthesis
#pragma warning restore SA1009 // Closing parenthesis must be spaced correctly
#pragma warning restore SA1515 // Single-line comment must be preceded by blank line
#pragma warning restore CA1307 // Specify StringComparison
#pragma warning restore CA1309 // Use ordinal stringcomparison
        }
예제 #4
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // Overflow is fine, just wrap
            unchecked
            {
                var hashCode = 41;

                // Suitable nullity checks etc, of course :)
#pragma warning disable CA1307 // Specify StringComparison

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (Name != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + Name.GetHashCode();
                }

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (VenueId != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + VenueId.GetHashCode();
                }

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (FriendIds != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + FriendIds.GetHashCode();
                }

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (TalkDraftIds != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + TalkDraftIds.GetHashCode();
                }
#pragma warning restore CA1307 // Specify StringComparison
                return(hashCode);
            }
        }