static void Main(string[] args) { // Клиентский код. Component1 component1 = new Component1(); Component2 component2 = new Component2(); Component3 component3 = new Component3(); new ConcreteMediator(component1, component2, component3); Console.WriteLine("Client triggets operation A."); component1.DoA(); Console.WriteLine(); Console.WriteLine("Client triggers operation D."); component2.DoD(); Console.WriteLine(); Console.WriteLine("Client triggers operation B."); component3.DoB(); Console.ReadLine(); }
public ConcreteMediator(Component1 component1, Component2 component2, Component3 component3) { this._component1 = component1; this._component1.SetMediator(this); this._component2 = component2; this._component2.SetMediator(this); this._component3 = component3; this._component3.SetMediator(this); }