コード例 #1
0
ファイル: Program.cs プロジェクト: joyOf/DesignPatterns
        static void Main(string[] args)
        {
            var concreteMediator = new ConcreteMediator();

            var c1 = new ConcreteColleague1();
            var c2 = new ConcreteColleague2();
            var c3 = new ConcreteColleague3();

            concreteMediator.Register(c1);
            concreteMediator.Register(c2);
            concreteMediator.Register(c3);

            c1.Send("Here's the message from C1");
            // c2.Send("Here's the message from C2");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: janeski/DesignPatterns
        static void Main(string[] args)
        {
            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.Read();
        }