Ejemplo n.º 1
0
        public void AddUser(string name)
        {
            bool userIsBanned = false;

            foreach (string user in BannedUsers)
            {
                if (name == user)
                {
                    userIsBanned = true;
                }
            }

            if (!userIsBanned)
            {
                UserAddedEventArgs args = new UserAddedEventArgs();
                args.Name = name;
                UserAdded(this, args);
                User newUser = new User();
                newUser.Name = name;
                Users.Add(newUser);
            }
            else
            {
                UserBannedEventArgs args = new UserBannedEventArgs();
                args.Name = name;
                UserBanned(this, args);
            }
        }
Ejemplo n.º 2
0
 static void OnUserAdded(object sender, UserAddedEventArgs args)
 {
     Console.WriteLine($"Welcome {args.Name}!");
 }