Ejemplo n.º 1
0
        static void  Main(string[] args)
        {
            var mediator   = new Mediator();
            var colleagueA = new ConcreteColleagueA(mediator);
            var colleagueB = new ConcreteColleagueB(mediator);

            mediator.ColleagueA = colleagueA;
            mediator.ColleagueB = colleagueB;
            colleagueA.SendMessage("你好B,中午一起饭吧?");
            colleagueB.SendMessage("你好A,好的。");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        private static void Main()
        {
            var mediator = new ConcreteMediator();

            var concreteColleagueA = new ConcreteColleagueA(mediator);
            var concreteColleagueB = new ConcreteColleagueB(mediator);

            mediator.ColleagueA = concreteColleagueA;
            mediator.ColleagueB = concreteColleagueB;

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

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static public void Main()
        {
            //构建具体类
            ConcreteMediator   concreteMediator   = new ConcreteMediator();
            ConcreteColleagueA concreteColleagueA = new ConcreteColleagueA(concreteMediator);
            ConcreteColleagueB concreteColleagueB = new ConcreteColleagueB(concreteMediator);
            ConcreteColleagueC concreteColleagueC = new ConcreteColleagueC(concreteMediator);

            //各司其职
            concreteColleagueA.DoSelfDuty();
            concreteColleagueB.DoSelfDuty();
            concreteColleagueC.DoSelfDuty();

            //得到最终产品
            FinalProduct finalProduct = concreteMediator.GetFinalProduct();
        }
Ejemplo n.º 4
0
        private static void Main()
        {
            var mediator = new ConcreteMediator();

            var concreteColleagueA = new ConcreteColleagueA(mediator);

            var concreteColleagueB = new ConcreteColleagueB(mediator);

            mediator.ColleagueA = concreteColleagueA;

            mediator.ColleagueB = concreteColleagueB;

            concreteColleagueA.Send("Message from ConcreteColleagueA");

            concreteColleagueB.Send("Message from ConcreteColleagueB");

            Console.ReadKey();
        }