internal IrcChannelUser(IrcUser user, IEnumerable<char> modes = null)
        {
            this.user = user;

            this.modes = new HashSet<char>();
            this.modesReadOnly = new ReadOnlySet<char>(this.modes);
            if (modes != null)
                this.modes.AddRange(modes);
        }
Exemple #2
0
        /// <summary>
        /// Gets the <see cref="IrcChannelUser"/> in the channel that corresponds to the specified
        /// <see cref="IrcUser"/>, or <see langword="null"/> if none is found.
        /// </summary>
        /// <param name="user">The <see cref="IrcUser"/> for which to look.</param>
        /// <returns>The <see cref="IrcChannelUser"/> in the channel that corresponds to the specified
        /// <see cref="IrcUser"/>, or <see langword="null"/> if none is found.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="user"/> is <see langword="null"/>.</exception>
        public IrcChannelUser GetChannelUser(IrcUser user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            return(this.users.SingleOrDefault(cu => cu.User == user));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IrcChannelInvitationEventArgs"/> class.
        /// </summary>
        /// <param name="channel">The channel to which the recipient user is invited.</param>
        /// <param name="inviter">The user inviting the recipient user to the channel.</param>
        public IrcChannelInvitationEventArgs(IrcChannel channel, IrcUser inviter)
            : base(channel)
        {
            if (inviter == null)
            {
                throw new ArgumentNullException("inviter");
            }

            this.Inviter = inviter;
        }
        /// <inheritdoc/>
        /// <summary>
        /// Initializes a new instance of the <see cref="IrcUserEventArgs"/> class.
        /// </summary>
        /// <param name="user">The user that the event concerns.</param>
        public IrcUserEventArgs(IrcUser user, string comment = null)
            : base(comment)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            this.User = user;
        }
Exemple #5
0
        internal IrcChannelUser(IrcUser user, IEnumerable <char> modes = null)
        {
            this.user = user;

            this.modes         = new HashSet <char>();
            this.modesReadOnly = new ReadOnlySet <char>(this.modes);
            if (modes != null)
            {
                this.modes.AddRange(modes);
            }
        }
Exemple #6
0
 internal void HandleUserInvited(IrcUser user)
 {
     lock (((ICollection)this.modesReadOnly).SyncRoot)
         OnUserInvited(new IrcUserEventArgs(user));
 }
Exemple #7
0
 internal void HandleUserKicked(IrcUser user, string comment)
 {
     lock (((ICollection)this.modesReadOnly).SyncRoot)
         HandleUserKicked(this.users.SingleOrDefault(u => u.User == user), comment);
 }
Exemple #8
0
 /// <inheritdoc cref="Invite(string)"/>
 /// <param name="user">The user to invite to the channel</param>
 public void Invite(IrcUser user)
 {
     Invite(user.NickName);
 }
Exemple #9
0
 internal void HandleInviteReceived(IrcUser inviter, IrcChannel channel)
 {
     OnInviteReceived(new IrcChannelInvitationEventArgs(channel, inviter));
 }
Exemple #10
0
 /// <inheritdoc cref="Invite(string)"/>
 /// <param name="user">The user to invite to the channel</param>
 public void Invite(IrcUser user)
 {
     Invite(user.NickName);
 }
Exemple #11
0
        /// <summary>
        /// Gets the user with the specified user name, creating it if necessary.
        /// </summary>
        /// <param name="userName">The user name of the user.</param>
        /// <param name="createdNew"><see langword="true"/> if the user object was created during the call;
        /// <see langword="false"/>, otherwise.</param>
        /// <returns>The user object that corresponds to the specified user name.</returns>
        protected IrcUser GetUserFromUserName(string userName, out bool createdNew)
        {
            if (userName == null)
                throw new ArgumentNullException("userName");
            if (userName.Length == 0)
                throw new ArgumentException(Properties.Resources.MessageValueCannotBeEmptyString, "userName");

            // Search for user with given nick name in list of known users. If it does not exist, add it.
            lock (((ICollection)this.usersReadOnly).SyncRoot)
            {
                var user = this.users.SingleOrDefault(u => u.UserName == userName);
                if (user == null)
                {
                    user = new IrcUser();
                    user.Client = this;
                    user.UserName = userName;
                    this.users.Add(user);

                    createdNew = true;
                }
                else
                {
                    createdNew = false;
                }

                return user;
            }
        }
Exemple #12
0
        /// <inheritdoc/>
        /// <summary>
        /// Initializes a new instance of the <see cref="IrcUserEventArgs"/> class.
        /// </summary>
        /// <param name="user">The user that the event concerns.</param>
        public IrcUserEventArgs(IrcUser user, string comment = null)
            : base(comment)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            this.User = user;
        }
Exemple #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IrcChannelInvitationEventArgs"/> class.
        /// </summary>
        /// <param name="channel">The channel to which the recipient user is invited.</param>
        /// <param name="inviter">The user inviting the recipient user to the channel.</param>
        public IrcChannelInvitationEventArgs(IrcChannel channel, IrcUser inviter)
            : base(channel)
        {
            if (inviter == null)
                throw new ArgumentNullException("inviter");

            this.Inviter = inviter;
        }
Exemple #14
0
 internal void HandleUserInvited(IrcUser user)
 {
     lock (((ICollection)this.modesReadOnly).SyncRoot)
         OnUserInvited(new IrcUserEventArgs(user));
 }
Exemple #15
0
 internal void HandleUserKicked(IrcUser user, string comment)
 {
     lock (((ICollection)this.modesReadOnly).SyncRoot)
         HandleUserKicked(this.users.SingleOrDefault(u => u.User == user), comment);
 }
Exemple #16
0
 internal void HandleInviteReceived(IrcUser inviter, IrcChannel channel)
 {
     OnInviteReceived(new IrcChannelInvitationEventArgs(channel, inviter));
 }
Exemple #17
0
        /// <summary>
        /// Gets the <see cref="IrcChannelUser"/> in the channel that corresponds to the specified
        /// <see cref="IrcUser"/>, or <see langword="null"/> if none is found.
        /// </summary>
        /// <param name="user">The <see cref="IrcUser"/> for which to look.</param>
        /// <returns>The <see cref="IrcChannelUser"/> in the channel that corresponds to the specified
        /// <see cref="IrcUser"/>, or <see langword="null"/> if none is found.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="user"/> is <see langword="null"/>.</exception>
        public IrcChannelUser GetChannelUser(IrcUser user)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            return this.users.SingleOrDefault(cu => cu.User == user);
        }