Example #1
0
        static void Main(string[] args)
        {
            Mediator           m  = new ConcreteMediator();
            ConcreteColleague1 c1 = new ConcreteColleague1(m);
            ConcreteColleague2 c2 = new ConcreteColleague2(m);
            ConcreteColleague3 c3 = new ConcreteColleague3(m);

            c1.Send("How are you?");
            c2.Send("Hello");
            c3.Send("Hi");

            Console.ReadLine();
        }
Example #2
0
        static void RunMediator()
        {
            // 中介含有所有具体的操作类 每个类含有一个中介
            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");
        }