Esempio n. 1
0
        static void Main(string[] args)
        {
            Mediator m = new Mediator();
            // Two from head office and one from a branch office
            Colleague  head1   = new Colleague(m, "John");
            ColleagueB branch1 = new ColleagueB(m, "David");
            Colleague  head2   = new Colleague(m, "Lucy");

            head1.Send("Meeting on Tuesday, please all ack");
            branch1.Send("Ack");      // by design does not get a copy
            m.Block(branch1.Receive); // temporarily gets no messages
            head1.Send("Still awaiting some Acks");
            head2.Send("Ack");
            m.Unblock(branch1.Receive); // open again
            head1.Send("Thanks all");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Mediator   m      = new Mediator();
            Colleague  head1  = new Colleague(m, "Megha");
            ColleagueB branch = new ColleagueB(m, "Test");
            Colleague  head2  = new Colleague(m, "Mohit");


            head1.Send("Meeting is there in Thursday, Plesae ack");
            branch.Send("Ack");
            m.Block(branch.Receive);
            head1.Send("Still waiting for Ack ");
            head2.Send("Ack");
            m.UnBlock(branch.Receive);
            head1.Send("Thanks All");
            Console.ReadLine();
        }
Esempio n. 3
0
        void Test()
        {
            mediator = new ConcreteMediator();

            colleague1 = new ConcreteColleague1(mediator);
            colleague2 = new ConcreteColleague2(mediator);

            mediator.Colleague1 = colleague1;
            mediator.Colleague2 = colleague2;

            colleague1.Send("同志们好!");
            colleague2.Send("首长好!");
        }