Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Irc.ChannelModeEventArgs"/> class.
        /// </summary>
        /// <param name="channelName">The channel that is the source of the mode change.</param>
        /// <param name="modeChanger">The nickname of the user that changed the channel modes, or null if none exists.</param>
        /// <param name="modeString">The mode string containing a list of added and removed channel modes.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if channelName is null.</exception>
        public ChannelModeEventArgs(IrcChannelName channelName, IrcNickname modeChanger, ChannelModeString modeString)
            : base(modeChanger)
        {
            if (channelName == null)
            {
                throw new ArgumentNullException(nameof(channelName));
            }

            ChannelName = channelName;

            ModeString = modeString;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="modeString"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static ChannelModeString operator +(ChannelModeString modeString, Mode mode)
        {
            ChannelModeString retVal = null;

            if (modeString == null)
            {
                retVal = new ChannelModeString(mode);
            }
            else
            {
                Mode[] newModeArray = new Mode[modeString.Length + 1];
                modeString._modes.CopyTo(newModeArray, 0);
                newModeArray[newModeArray.Length - 1] = mode;

                retVal = new ChannelModeString(newModeArray);
            }

            return(retVal);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        /// <returns></returns>
        public static ChannelModeString operator +(ChannelModeString first, ChannelModeString second)
        {
            ChannelModeString retVal = null;

            if (first != null && second == null)
            {
                retVal = first;
            }
            else if (first == null && second != null)
            {
                retVal = second;
            }
            else if (first != null && second != null)
            {
                Mode[] newModeArray = new Mode[first.Length + second.Length];
                first._modes.CopyTo(newModeArray, 0);
                second._modes.CopyTo(newModeArray, first.Length);

                retVal = new ChannelModeString(newModeArray);
            }

            return(retVal);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Deletes the specified number of <see cref="Irc.Mode">Irc.Modes</see> from this
        /// <see cref="Irc.ChannelModeString"/> starting from the specified index.
        /// </summary>
        /// <param name="startIndex">The zero-based index from which
        /// to start deleting <see cref="Irc.Mode">Irc.Modes</see>.</param>
        /// <param name="count">The number of <see cref="Irc.Mode">Irc.Modes</see> to delete.</param>
        /// <returns>A new <see cref="Irc.ChannelModeString"/> with the specified number of modes removed.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown if startIndex or count is not in the bounds of the array.</exception>
        public ChannelModeString Remove(int startIndex, int count)
        {
            if (startIndex < 0 || startIndex >= Length)
            {
                throw new ArgumentOutOfRangeException(nameof(startIndex));
            }
            if (count < 0 || count > Length - startIndex)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            ChannelModeString retVal = null;

            if (startIndex > 0)
            {
                Mode[] newModeArray = new Mode[Length - count];
                Array.Copy(_modes, 0, newModeArray, 0, startIndex);
                Array.Copy(_modes, startIndex + count, newModeArray, startIndex, Length - startIndex - count);

                retVal = new ChannelModeString(newModeArray);
            }

            return(retVal);
        }