Ejemplo n.º 1
0
        /// <summary>
        /// Triggers when an user has changed his/her nickname, or the server assigns a nickname
        /// </summary>
        /// <param name="oldNickname">What the nickname used to be</param>
        /// <param name="newNickname">The new nickname being used</param>
        /// <param name="type">Defines if the user changed his/her name, or if the server assigned a nickname</param>
        protected virtual void OnNicknameChanged(string oldNickname, string newNickname, NicknameChangedType type)
        {
            if (oldNickname == null) throw new ArgumentNullException(nameof(oldNickname), "Old nickname not provided.");
            if (newNickname == null) throw new ArgumentNullException(nameof(newNickname), "New nickname not provided.");
            if (!Enum.IsDefined(typeof(NicknameChangedType), type))
                throw new ArgumentOutOfRangeException(nameof(type));

            EventHandler<NicknameChangedEventArgs> handler = NicknameChanged;
            handler?.Invoke(this, new NicknameChangedEventArgs { NewNickname = newNickname, OldNickname = oldNickname, Type = type });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Triggers when an user has changed his/her nickname, or the server assigns a nickname
        /// </summary>
        /// <param name="oldNickname">What the nickname used to be</param>
        /// <param name="newNickname">The new nickname being used</param>
        /// <param name="type">Defines if the user changed his/her name, or if the server assigned a nickname</param>
        protected virtual void OnNicknameChanged(string oldNickname, string newNickname, NicknameChangedType type)
        {
            if (oldNickname == null)
            {
                throw new ArgumentNullException(nameof(oldNickname), "Old nickname not provided.");
            }
            if (newNickname == null)
            {
                throw new ArgumentNullException(nameof(newNickname), "New nickname not provided.");
            }
            if (!Enum.IsDefined(typeof(NicknameChangedType), type))
            {
                throw new ArgumentOutOfRangeException(nameof(type));
            }

            EventHandler <NicknameChangedEventArgs> handler = NicknameChanged;

            handler?.Invoke(this, new NicknameChangedEventArgs {
                NewNickname = newNickname, OldNickname = oldNickname, Type = type
            });
        }