Using system; using system. LINQ; using system. text; namespace designpatterns. mediator {// mediatorr abstract class abstractchatroom {public abstract void register (FIG); public abstract void send (string from, string to, string message);} // concretemediator class chatroom: abstractchatroom {private system. collections. hashtable participant ipants = new system. collections. hashtable (); Pub LIC override void register (maid) {If (maid [particle ant. name] = NULL) {maid [participant. name] = maid;} maid. chatroom = This;} public override void send (string from, string to, string message) {particle ant PTO = (particle ant) maid [to]; If (PTO! = NULL) {PTO. receive (from, message );}}} /*************************************** **************************************** * ** // abstractcollegou class participant ipant {private chatroom; private string name; // constructor Public Participant ipant (string name) {This. name = Name;} // properties public string name {get {return name;} public chatroom {set {chatroom = value;} get {Return chatroom ;}} public void send (string to, string message) {chatroom. send (name, to, message);} Public Virtual void receive (string from, string message) {console. writeline ("{0} to {1}: '{2}'", from, name, message) ;}// concretecolleaguel class Beatle: participant ipant {// constructor public beatle (string name): Base (name) {} public override void receive (string from, string message) {consol E. write ("to a Beatle:"); base. receive (from, message) ;}/// concretecolleague2 class nonbeatle: FIG {// constructor public nonbeatle (string name): Base (name) {} public override void receive (string from, string message) {console. write ("to a non-Beatle:"); base. receive (from, message) ;}} class program {// The client calls the following: static void main (string [] ARGs) {// create chatroom = New chatroom (); // create participant ants and register them participant ipant George = new beatle ("George"); participant ipant Paul = new beatle ("PAUL "); particle ant Ringo = new beatle ("ringo"); particle ant John = new nonbeatle ("John"); particle ant Yoko = new nonbeatle ("Yoko"); chatroom. register (George); chatroom. register (Paul); chatroom. register (Ringo); chatroom. register (John); chatroom. register (Yoko); // chattin G participant ipants George. Send ("Yoko", "You are wrong"); Yoko. Send ("George", "what is wrong? "); // Yoko. send ("John", "Hi John"); // Paul. send ("ringo", "All you need is love"); // Ringo. send ("George", "My sweet Lord"); // Paul. send ("John", "can't buy me love"); // John. send ("Yoko", "My sweet love"); console. readkey ();}}}