Mediator Pattern Code Review
Define the Mediator Object
Code Download
- Download Description:mediator pattern download
- .NET Framework:3.5
- .NET Language:C#
- Date Published:2009-07-01
- Download Size:8 KB
Code Review
- Mediator Pattern Code Review: Define the Mediator Object
- Mediator Pattern Code Review: Define the Colleague Objects
- Mediator Pattern Code Review: Use the Mediator Pattern
Code Walkthrough
Define the Mediator class (object) which is responsible for managing messages that are exchanged between colleagues.
class Mediator
{
public delegate void Callback (String message, String from);
Callback respond;
public void SignOn(Callback method) { respond += method; } public void Block(Callback method) { respond -= method; } public void Unblock(Callback method) { respond += method; } public void Send(String message, String from) { respond(message, from); Console.WriteLine(); } }
public void SignOn(Callback method) { respond += method; } public void Block(Callback method) { respond -= method; } public void Unblock(Callback method) { respond += method; } public void Send(String message, String from) { respond(message, from); Console.WriteLine(); } }
Callback methods are used to invoke the Receive() method on the relevant Colleagues classes (objects).
Printer Friendly Version
Add to Favourites
DotNet Kicks
Digg
del.icio.us
Live Favourites
ma.gnolia
reddit
Slashdot
Technorati
Yahoo!