コード例 #1
0
 public ConcreteMediator(Component1 component1, Component2 component2)
 {
     _component1 = component1;
     _component1.SetMediator(this);
     _component2 = component2;
     _component2.SetMediator(this);
 }
コード例 #2
0
        private static void Main()
        {
            var component1       = new Component1();
            var component2       = new Component2();
            var concreteMediator = new ConcreteMediator(component1, component2);

            Console.WriteLine("Client triggers operation A.");
            component1.DoA();
            Console.WriteLine();
            Console.WriteLine("Client triggers operation D.");
            component2.DoD();

            concreteMediator.Notify(55, "A");
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Component1 component1 = new Component1();
            Component2 component2 = new Component2();

            new ConcreteMediator(component1, component2);

            Console.WriteLine("Client triggets operation A.");
            component1.DoA();

            Console.WriteLine();

            Console.WriteLine("Client triggers operation D.");
            component2.DoD();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            // Клиентский код.
            Component1 component1 = new Component1();
            Component2 component2 = new Component2();

            new ConcreteMediator(component1, component2);

            Console.WriteLine("Client triggets operation A.");
            component1.DoA();

            Console.WriteLine();

            Console.WriteLine("Client triggers operation D.");
            component2.DoD();
            //-----------------------------------------------------------------


            ManagerMediator mediator = new ManagerMediator();

            Colleague customer   = new CustomerColleague(mediator);
            Colleague programmer = new ProgrammerColleague(mediator);
            Colleague tester     = new TesterColleague(mediator);

            mediator.Customer   = customer;
            mediator.Programmer = programmer;
            mediator.Tester     = tester;

            customer.Send("Есть заказ, надо сделать программу");
            programmer.Send("Программа готова, надо протестировать");
            tester.Send("Программа протестирована и готова к продаже");


            Console.WriteLine("Press any key to continue....");
            Console.ReadLine();
        }
コード例 #5
0
 public Mediator()
 {
     Component1 = new Component1();
     Component2 = new Component2();
 }
コード例 #6
0
 public ConcreteMediator()
 {
     this.Component1 = new Component1(this);
     this.Component2 = new Component1(this);
 }