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

Example of using the Mediator Pattern in C#. More...

Collaboration diagram for Mediator_Exercise:
Collaboration graph

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.
 

Detailed Description

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.

Member Function Documentation

◆ _ListToString()

string _ListToString ( string[]  items)
inlineprivate

Helper method to convert a list of strings to a comma-delimited list in a single string.

Parameters
itemsThe list of strings to convert.
Returns
A string containing a comma-delimited format of strings.

Definition at line 31 of file Mediator_Exercise.cs.

Referenced by Mediator_Exercise.Run().

◆ Mediator_SetupGroups()

void Mediator_SetupGroups ( UserGroupMediator  mediator)
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.

Parameters
mediatorThe mediator object that owns the list of groups.

Definition at line 64 of file Mediator_Exercise.cs.

References UserGroupMediator.AddGroup(), and UserGroupMediator.AddUserToGroup().

◆ Mediator_SetupUsers()

void Mediator_SetupUsers ( UserGroupMediator  mediator)
inlineprivate

Helper method to add a number of users to the Users list.

Parameters
mediatorThe mediator object that owns the list of users.

Definition at line 49 of file Mediator_Exercise.cs.

References UserGroupMediator.AddUser().

◆ Run()


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