Пример #1
0
        /// <summary>
        /// Sets the users of the <see cref="IrcChannel"/> using a sequence of nicknames from a NAMES reply.
        /// </summary>
        internal void SetUsers(IEnumerable <string> prefixedNicknames)
        {
            // The trick here is that since IrcUserChannelModePairs implement INotifyPropertyChanged,
            // the existing ones have to be kept because someone may listen to their events
            // and obviously expect that if an user is still there, the objects representing them won't change.

            var pairs = new List <IrcUserChannelModePair>();

            foreach (string nick in prefixedNicknames)
            {
                var split = IrcChannel.SplitName(nick, this.Network.Parameters);
                var user  = this.Network.GetUser(split.Name);
                var mode  = IrcChannel.GetUserMode(split.Modifier, this.Network.Parameters);
                var pair  = this.UserModes.FirstOrDefault(p => p.User == user);

                if (pair == null)
                {
                    pair = new IrcUserChannelModePair(user, mode);
                }
                else
                {
                    pair.Mode = mode;
                }

                pairs.Add(pair);

                if (!user.Channels.Contains(this))
                {
                    user.ChannelsInternal.Add(this);
                }
            }

            this.UserModes.SetItems(pairs);
        }
Пример #2
0
        /// <summary>
        /// Adds the specified <see cref="IrcUser"/> in the <see cref="IrcChannel"/>.
        /// </summary>
        internal void AddUser(IrcUser user)
        {
            var pair = new IrcUserChannelModePair(user, IrcChannelUserModes.Normal);

            this.UserModes.Add(pair);

            user.ChannelsInternal.Add(this);
        }