Пример #1
0
        static void Main()
        {
            var mediator        = new Mediator();
            var firstColleague  = new ColleagueA(mediator);
            var secondColleague = new ColleagueB(mediator);

            firstColleague.Send();
            secondColleague.Receive();
            mediator.SendMessage(firstColleague);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Using structural code : ");
            Console.WriteLine();

            Mediator mediator = new Mediator();

            ColleagueA colleagueA = new ColleagueA(mediator);
            ColleagueB colleagueB = new ColleagueB(mediator);

            mediator.ColleagueA = colleagueA;
            mediator.ColleagueB = colleagueB;

            colleagueA.Send("Hi! I'm colleagueA");
            colleagueB.Send("Hi! I'm colleagueB");

            Console.ReadLine();

            Console.WriteLine("Using real-world code : ");
            Console.WriteLine();

            Console.ReadLine();
        }
Пример #3
0
        static void Main(string[] args)
        {
            ConcreteMediator mediator = new ConcreteMediator();

            ColleagueA colleagueA = new ColleagueA(mediator);
            ColleagueB colleagueB = new ColleagueB(mediator);

            mediator.SetColleagueA(colleagueA);
            mediator.SetColleagueB(colleagueB);

            colleagueB.Send("Hello A");
            colleagueA.Send("Hello B");


            CustomerServericeMM customerMM = new CustomerServericeMM();
            Customer            customer   = new Customer(customerMM);
            Techician           techician  = new Techician(customerMM);

            customerMM.SetCustomer(customer);
            customerMM.SetTechicain(techician);

            customer.Ask("客户提问");
            techician.Answer("技术支持解答");
        }
Пример #4
0
 public Mediator(ColleagueA colleagueA, ColleagueB colleagueB)
 {
     this.ColleagueA = colleagueA;
     this.ColleagueB = colleagueB;
 }
Пример #5
0
 public MediatorB(ColleagueA colleagueA, ColleagueB colleagueB)
     : base(colleagueA, colleagueB)
 {
 }
Пример #6
0
 public void SetColleagueA(ColleagueA colleagueA)
 {
     this.colleagueA = colleagueA;
 }