Design Pattern Examples
Overview of object-oriented design patterns
UserList Class Reference

Represents a list of users. More...

Collaboration diagram for UserList:
Collaboration graph

Public Member Functions

UserFindUser (string name)
 Retrieve the User instance for the specified user name.
 
void AddUser (string name)
 Add the specified user name as a user. Operation ignored if user is already in the list.
 
void RemoveUser (string name)
 Remove the specified user name as a user. Operation ignored if user is not in the list.
 

Properties

string[] UserNames [get]
 The user names contained in this list (read-only). The list is always sorted.
 

Private Attributes

List< User_users = new List<User>()
 The list of users.
 

Detailed Description

Represents a list of users.

This is a simple implementation using a simple list. It is NOT thread-safe.

Definition at line 87 of file Mediator_User_Classes.cs.

Member Function Documentation

◆ AddUser()

void AddUser ( string  name)
inline

Add the specified user name as a user. Operation ignored if user is already in the list.

Parameters
nameName of user to add. Cannot be null or empty.
Exceptions
ArgumentNullExceptionThe 'name' parameter is null or empty.

Definition at line 130 of file Mediator_User_Classes.cs.

References UserList._users.

Referenced by UserGroupMediator.AddUser().

◆ FindUser()

User? FindUser ( string  name)
inline

Retrieve the User instance for the specified user name.

Parameters
nameUser name to search for.
Returns
Returns a User object if name found. Returns null if not found.

Definition at line 118 of file Mediator_User_Classes.cs.

References UserList._users.

Referenced by UserList.AddUser(), UserGroupMediator.AddUserToGroup(), UserGroupMediator.GetGroupsWithUser(), UserGroupMediator.IsUserInGroup(), UserGroupMediator.RemoveUserFromAllGroups(), and UserGroupMediator.RemoveUserFromGroup().

◆ RemoveUser()

void RemoveUser ( string  name)
inline

Remove the specified user name as a user. Operation ignored if user is not in the list.

Parameters
nameName of user to remove.

Definition at line 150 of file Mediator_User_Classes.cs.

References UserList._users.

Referenced by UserGroupMediator.RemoveUser().

Member Data Documentation

◆ _users

Property Documentation

◆ UserNames

string [] UserNames
get

The user names contained in this list (read-only). The list is always sorted.

Definition at line 98 of file Mediator_User_Classes.cs.

Referenced by UserGroupMediator.GetAllUsers().


The documentation for this class was generated from the following file: