Example of using the Mediator Pattern in C#. More...
Public Member Functions | |
void | Run () |
Executes the example for the Mediator Pattern in C#. | |
Private Member Functions | |
string | _ListToString (string[] items) |
Helper method to convert a list of strings to a comma-delimited list in a single string. | |
void | Mediator_SetupUsers (UserGroupMediator mediator) |
Helper method to add a number of users to the Users list. | |
void | Mediator_SetupGroups (UserGroupMediator mediator) |
Helper method to add a number of groups to the Groups list and then add users to the groups. Note that everything here is done with names. | |
Example of using the Mediator Pattern in C#.
A mediator is instantiated then populated with users and groups. Users are added to some of the groups.
A series of operations are then performed through the mediator. The output shows the results of each operation. Note that all operations are done using user and group names, with no knowledge of the actual lists of users and groups. The mediator hides all the details.
Definition at line 23 of file Mediator_Exercise.cs.
|
inlineprivate |
Helper method to convert a list of strings to a comma-delimited list in a single string.
items | The list of strings to convert. |
Definition at line 31 of file Mediator_Exercise.cs.
Referenced by Mediator_Exercise.Run().
|
inlineprivate |
Helper method to add a number of groups to the Groups list and then add users to the groups. Note that everything here is done with names.
mediator | The mediator object that owns the list of groups. |
Definition at line 64 of file Mediator_Exercise.cs.
References UserGroupMediator.AddGroup(), and UserGroupMediator.AddUserToGroup().
|
inlineprivate |
Helper method to add a number of users to the Users list.
mediator | The mediator object that owns the list of users. |
Definition at line 49 of file Mediator_Exercise.cs.
References UserGroupMediator.AddUser().
|
inline |
Executes the example for the Mediator Pattern in C#.
Definition at line 84 of file Mediator_Exercise.cs.
References Mediator_Exercise._ListToString(), UserGroupMediator.AddUserToGroup(), UserGroupMediator.GetAllGroups(), UserGroupMediator.GetAllUsers(), UserGroupMediator.GetGroupsWithUser(), UserGroupMediator.GetUsersInGroup(), UserGroupMediator.IsUserInGroup(), Mediator_SetupGroups(), Mediator_SetupUsers(), UserGroupMediator.RemoveUser(), UserGroupMediator.RemoveUserFromAllGroups(), and UserGroupMediator.RemoveUserFromGroup().
Referenced by Program.Run().