Represents the mediator between caller, users, and groups. All users and groups are identified by string name. The names are case-sensitive. More...
Public Member Functions | |
void | AddUser (string name) |
Add a user to the list of known users. If the name is already in the list of users, the request to add is ignored. | |
void | RemoveUser (string name) |
Removes the specified user from the list of known users, if the user exists. Also removes the user from all groups. | |
void | AddGroup (string name) |
Add a group to the list of known groups. If the group is already in the list, the request to add is ignored. | |
void | RemoveGroup (string name) |
Remove the specified group from the list of known groups if the group exists. | |
void | AddUserToGroup (string userName, string groupName) |
Add the specified user to the specified group. If the user is already in the group, do nothing. The user must exist. | |
void | RemoveUserFromGroup (string userName, string groupName) |
Remove the specified user from the specified group. | |
void | RemoveUserFromAllGroups (string userName) |
Remove the specified user from all existing groups. | |
bool | IsUserInGroup (string userName, string groupName) |
Determine if the specified user is in the specified group. | |
string[] | GetGroupsWithUser (string userName) |
Retrieve a list of all groups that contain the specified user. | |
string[] | GetUsersInGroup (string groupName) |
Retrieve a list of users in the specified group. | |
string[] | GetAllGroups () |
Retrieve a list of all known groups. | |
string[] | GetAllUsers () |
Retrieve a list of all known users. | |
Private Attributes | |
UserGroupsContainer | _userGroupsContainer = new UserGroupsContainer() |
Represents the mediator between caller, users, and groups. All users and groups are identified by string name. The names are case-sensitive.
Definition at line 35 of file Mediator_Class.cs.
|
inline |
Add a group to the list of known groups. If the group is already in the list, the request to add is ignored.
ArgumentNullException | The 'name' parameter cannot be null or empty. |
name | Name of the user to add. Must not be null or empty. |
Definition at line 72 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, GroupList.AddGroup(), and UserGroupsContainer.Groups.
Referenced by Mediator_Exercise.Mediator_SetupGroups().
|
inline |
Add a user to the list of known users. If the name is already in the list of users, the request to add is ignored.
name | Name of the user to add. Must not be null or empty. |
ArgumentNullException | The 'name' parameter cannot be null or empty. |
Definition at line 48 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, UserList.AddUser(), and UserGroupsContainer.Users.
Referenced by Mediator_Exercise.Mediator_SetupUsers().
|
inline |
Add the specified user to the specified group. If the user is already in the group, do nothing. The user must exist.
userName | Name of user to add. Must be an existing user. |
groupName | Name of group to add user to. Must be an existing group. |
ArgumentException | User or group does not exist. |
Definition at line 96 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, Group.AddUser(), GroupList.FindGroup(), UserList.FindUser(), UserGroupsContainer.Groups, and UserGroupsContainer.Users.
Referenced by Mediator_Exercise.Mediator_SetupGroups(), and Mediator_Exercise.Run().
|
inline |
Retrieve a list of all known groups.
Definition at line 265 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, GroupList.GroupNames, and UserGroupsContainer.Groups.
Referenced by Mediator_Exercise.Run().
|
inline |
Retrieve a list of all known users.
Definition at line 275 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, UserList.UserNames, and UserGroupsContainer.Users.
Referenced by Mediator_Exercise.Run().
|
inline |
Retrieve a list of all groups that contain the specified user.
userName | Name of the user to look for. Must be an existing user. |
ArgumentException | User or group does not exist. |
Definition at line 217 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, Group.ContainsUser(), GroupList.FindGroup(), UserList.FindUser(), GroupList.GroupNames, UserGroupsContainer.Groups, and UserGroupsContainer.Users.
Referenced by Mediator_Exercise.Run().
|
inline |
Retrieve a list of users in the specified group.
groupName | Name of the group to examine. Must be an existing group. |
ArgumentException | Group does not exist. |
Definition at line 249 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, GroupList.FindGroup(), UserGroupsContainer.Groups, and Group.Users.
Referenced by Mediator_Exercise.Run().
|
inline |
Determine if the specified user is in the specified group.
userName | Name of user to find. Must be an existing user. |
groupName | Name of group to look in. Must be an existing group. |
ArgumentException | User or group does not exist. |
Definition at line 186 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, Group.ContainsUser(), GroupList.FindGroup(), UserList.FindUser(), UserGroupsContainer.Groups, and UserGroupsContainer.Users.
Referenced by Mediator_Exercise.Run().
|
inline |
Remove the specified group from the list of known groups if the group exists.
name | Name of group to remove. |
Definition at line 83 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, UserGroupsContainer.Groups, and GroupList.RemoveGroup().
|
inline |
Removes the specified user from the list of known users, if the user exists. Also removes the user from all groups.
name | Name of user to remove. |
Definition at line 59 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, UserList.RemoveUser(), UserGroupMediator.RemoveUserFromAllGroups(), and UserGroupsContainer.Users.
Referenced by Mediator_Exercise.Run().
|
inline |
Remove the specified user from all existing groups.
userName | Name of user to remove. Must be an existing user. |
ArgumentException | User does not exist. |
Definition at line 153 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, Group.ContainsUser(), GroupList.FindGroup(), UserList.FindUser(), GroupList.GroupNames, UserGroupsContainer.Groups, Group.RemoveUser(), and UserGroupsContainer.Users.
Referenced by UserGroupMediator.RemoveUser(), and Mediator_Exercise.Run().
|
inline |
Remove the specified user from the specified group.
userName | Name of user to remove. Must be an existing user. |
groupName | Name of group to remove user from. Must be an existing group. |
ArgumentException | User or group does not exist. |
Definition at line 125 of file Mediator_Class.cs.
References UserGroupMediator._userGroupsContainer, GroupList.FindGroup(), UserList.FindUser(), UserGroupsContainer.Groups, Group.RemoveUser(), and UserGroupsContainer.Users.
Referenced by Mediator_Exercise.Run().
|
private |
Definition at line 39 of file Mediator_Class.cs.
Referenced by UserGroupMediator.AddGroup(), UserGroupMediator.AddUser(), UserGroupMediator.AddUserToGroup(), UserGroupMediator.GetAllGroups(), UserGroupMediator.GetAllUsers(), UserGroupMediator.GetGroupsWithUser(), UserGroupMediator.GetUsersInGroup(), UserGroupMediator.IsUserInGroup(), UserGroupMediator.RemoveGroup(), UserGroupMediator.RemoveUser(), UserGroupMediator.RemoveUserFromAllGroups(), and UserGroupMediator.RemoveUserFromGroup().