/// <summary>
 ///   Get a Friend from an IBefriendable.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to return the Friend instance for.</param>
 /// <returns>The instance of Friend for befriendable. If befriendable is not a friend then null is returned.</returns>
 public Friend GetFriend(IBefriendable befriendable)
 {
     if (!_friends.ContainsKey(befriendable.GetID()))
     {
         return(null);
     }
     return(_friends[befriendable.GetID()]);
 }
        /// <summary>
        ///   Add an IBefriendable as a friend only if the IBefriendable is not already a friend.
        /// </summary>
        /// <param name = "befriendable">The IBefriendable to add.</param>
        /// <returns>The instance of MessengerObject this was called on. This allows for chaining.</returns>
        public MessengerObject AddNewFriend(IBefriendable befriendable)
        {
            if (_friends.ContainsKey(befriendable.GetID()))
            {
                return(this);
            }

            Friend friend = new Friend(befriendable);

            _friends.Add(befriendable.GetID(), friend);

            return(this);
        }
        /// <summary>
        /// </summary>
        /// <param name = "befriendable"></param>
        /// <returns></returns>
        public MessengerObject RemoveFriendRequest(IBefriendable befriendable)
        {
            if (!_friendRequests.ContainsKey(befriendable.GetID()))
            {
                return(this);
            }

            _friendRequests.Remove(befriendable.GetID());

            if (OnFriendRequestRemoved != null)
            {
                OnFriendRequestRemoved.Invoke(this, new MessengerFriendRequestEventArgs(befriendable, Owner));
            }

            return(this);
        }
        public MessengerObject AddFriendToCategory(IBefriendable befriendable, Category category)
        {
            if (!_friends.ContainsKey(befriendable.GetID()))
            {
                return(this);
            }

            Friend friend = _friends[befriendable.GetID()];

            if (!friend.Categories.ContainsKey(category.ID))
            {
                friend.Categories.Add(category.ID, category);
            }

            if (!category.Friends.ContainsKey(befriendable.GetID()))
            {
                category.Friends.Add(befriendable.GetID(), befriendable);
            }
            return(this);
        }
 /// <summary>
 ///   Check if an IBefriendable is already an friend.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to check for.</param>
 /// <returns>True if befriendable is already a friend, false otherwise.</returns>
 public bool IsFriend(IBefriendable befriendable)
 {
     return(_friends.ContainsKey(befriendable.GetID()));
 }
 /// <summary>
 ///   Check if there is an outstanding request from an IBefriendable.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to check for requests from.</param>
 /// <returns>True if befriendable is already a friend, false otherwise.</returns>
 public bool IsRequestedBy(IBefriendable befriendable)
 {
     return(_friendRequests.ContainsKey(befriendable.GetID()));
 }
 public MessengerObject RemoveFriendFromCategory(IBefriendable befriendable, Category category)
 {
     RemoveFriendFromCategory(befriendable.GetID(), category);
     return(this);
 }
 public MessengerObject RemoveFriend(IBefriendable befriendable)
 {
     RemoveFriend(befriendable.GetID());
     return(this);
 }
        /// <summary>
        /// </summary>
        /// <param name = "befriendable"></param>
        /// <returns></returns>
        public MessengerObject RemoveFriendRequest(IBefriendable befriendable)
        {
            if (!_friendRequests.ContainsKey(befriendable.GetID()))
                return this;

            _friendRequests.Remove(befriendable.GetID());

            if (OnFriendRequestRemoved != null)
                OnFriendRequestRemoved.Invoke(this, new MessengerFriendRequestEventArgs(befriendable, Owner));

            return this;
        }
 public MessengerObject RemoveFriend(IBefriendable befriendable)
 {
     RemoveFriend(befriendable.GetID());
     return this;
 }
 public MessengerObject RemoveFriendFromCategory(IBefriendable befriendable, Category category)
 {
     RemoveFriendFromCategory(befriendable.GetID(), category);
     return this;
 }
 /// <summary>
 ///   Check if there is an outstanding request from an IBefriendable.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to check for requests from.</param>
 /// <returns>True if befriendable is already a friend, false otherwise.</returns>
 public bool IsRequestedBy(IBefriendable befriendable)
 {
     return _friendRequests.ContainsKey(befriendable.GetID());
 }
 /// <summary>
 ///   Check if an IBefriendable is already an friend.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to check for.</param>
 /// <returns>True if befriendable is already a friend, false otherwise.</returns>
 public bool IsFriend(IBefriendable befriendable)
 {
     return _friends.ContainsKey(befriendable.GetID());
 }
 /// <summary>
 ///   Get a Friend from an IBefriendable.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to return the Friend instance for.</param>
 /// <returns>The instance of Friend for befriendable. If befriendable is not a friend then null is returned.</returns>
 public Friend GetFriend(IBefriendable befriendable)
 {
     if (!_friends.ContainsKey(befriendable.GetID()))
         return null;
     return _friends[befriendable.GetID()];
 }
        /// <summary>
        ///   Add an IBefriendable as a friend only if the IBefriendable is not already a friend.
        /// </summary>
        /// <param name = "befriendable">The IBefriendable to add.</param>
        /// <returns>The instance of MessengerObject this was called on. This allows for chaining.</returns>
        public MessengerObject AddNewFriend(IBefriendable befriendable)
        {
            if (_friends.ContainsKey(befriendable.GetID()))
                return this;

            Friend friend = new Friend(befriendable);
            _friends.Add(befriendable.GetID(), friend);

            return this;
        }
        public MessengerObject AddFriendToCategory(IBefriendable befriendable, Category category)
        {
            if (!_friends.ContainsKey(befriendable.GetID()))
                return this;

            Friend friend = _friends[befriendable.GetID()];

            if (!friend.Categories.ContainsKey(category.ID))
                friend.Categories.Add(category.ID, category);

            if (!category.Friends.ContainsKey(befriendable.GetID()))
                category.Friends.Add(befriendable.GetID(), befriendable);
            return this;
        }