Пример #1
0
        static void Main(string[] args)
        {
            ConcreteMediator  mediator  = new ConcreteMediator();
            ConcreteCollegue1 collegue1 = new ConcreteCollegue1(mediator);
            ConcreteCollegue2 collegue2 = new ConcreteCollegue2(mediator);

            mediator.Collegue1 = collegue1;
            mediator.Collegue2 = collegue2;
            collegue1.Send("Hello from collegue 1");
            collegue2.Send("Hello from collegue 2");
        }
Пример #2
0
        static void Main(string[] args)
        {
            ConcreteMediator m = new ConcreteMediator();

            ConcreteCollegue1 c1 = new ConcreteCollegue1(m);
            ConcreteCollegue2 c2 = new ConcreteCollegue2(m);

            m.ConcreteCollegue1 = c1;
            m.ConcreteCollegue2 = c2;

            c1.Send("呃呃呃");
            c2.Send("呼呼呼");

            Console.Read();
        }