Exemplo n.º 1
0
        /// <summary>
        /// Set a user's name.
        /// This might thrown an exception.
        /// </summary>
        /// <param name="name">Name to give user</param>
        /// <exception cref="Exception">Throws exception</exception>
        public void SetName(string name)
        {
            INameState state = new InvalidName();

            if (state.ValidateName(name).isValid)
            {
                this.Name = name;
                return;
            }
            ;

            throw new Exception();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Notifies subscribers of InvalidName event.
 /// </summary>
 /// <param name="e">Args containing info about the source (name) and the Name object (parser's best guess for the parsing).</param>
 protected virtual void OnInvalidName(InvalidNameEventArgs e) => InvalidName?.Invoke(this, e);