Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Mediator Pattern Demo***\n");
            ConcretMediator m = new ConcretMediator();

            Friend1 Amit  = new Friend1(m, "Amit");
            Friend2 Sohel = new Friend2(m, "Sohel");
            Boss    Raghu = new Boss(m, "Raghu");

            m.SetFriend1 = Amit;
            m.setFriend2 = Sohel;
            m.setBoss    = Raghu;

            Amit.Send("[Amit here]Good Morrning. Can we discuss the mediator pattern?");
            Sohel.Send("[Sohel here]Good Morning.Yes, we can discuss now.");
            Raghu.Send("\n[Raghu here]:Please get back to work quickly");

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Mediator Pattern Demo***\n");

            ConcreteMediator mediator = new ConcreteMediator();

            Friend1 Amit  = new Friend1(mediator, "Amit");
            Friend1 Sohel = new Friend1(mediator, "Sohel");
            Boss    Raghu = new Boss(mediator, "Raghu");

            mediator.Register(Amit);
            mediator.Register(Sohel);
            mediator.Register(Raghu);
            mediator.DisplayDetails();

            Console.WriteLine("Communication starts among participants...");
            Amit.Send("Hi Sohel, can we discuss the mediator pattern?");
            Sohel.Send("Hi Amit, Yup, we can discuss now.");
            Raghu.Send("Please get back to work quickly.");

            Unknown unknown = new Unknown(mediator, "Jack");

            unknown.Send("Hello Gusy...");
        }