public ConcreteMediator(Component1 component1, Component2 component2) { this.component1 = component1; this.component1.setMediator(this); this.component2 = component2; this.component2.setMediator(this); }
public static void ClientCode() { Component1 component1 = new Component1(); Component2 component2 = new Component2(); Mediator mediator = new ConcreteMediator(component1, component2); Console.Write("Client triggets operation A.\n"); component1.doA(); Console.WriteLine(); Console.Write("Client triggers operation D.\n"); component2.doD(); }