Ejemplo n.º 1
0
        static void Invock21()
        {
            ConcreteMediator mediator = new ConcreteMediator();
            var colleague1            = new ConcreteColleague1(mediator);
            var colleague2            = new ConcreteColleague2(mediator);

            mediator.Colleague1 = colleague1;
            mediator.Colleague2 = colleague2;

            colleague1.Send("colleague1 send了一个message");
            colleague2.Send("colleague1 send了一个message");
        }
Ejemplo n.º 2
0
        public static void MediatorDemo()
        {
            ConcreteMediator m = new ConcreteMediator();

            ConcreteColleague1 c1 = new ConcreteColleague1(m);
            ConcreteColleague2 c2 = new ConcreteColleague2(m);

            m.Colleague1 = c1;
            m.Colleague2 = c2;

            c1.Send("How are you?");
            c2.Send("Fine, thanks");

            // Wait for user

            Console.ReadKey();
        }