Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ConcreteMediator m = new ConcreteMediator();
            ColleagueA       a = new ColleagueA(m);
            ColleagueB       b = new ColleagueB(m);

            m.A = a;
            m.B = b;

            a.Send("在干吗?");
            b.Send("打游戏");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
    static void MainRun()
    {
        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");
    }
Ejemplo n.º 3
0
    public void Main()
    {
        var m = new Mediator();
        // Two from head office and one from a branch office
        var head1 = new Colleague(m, "John");
        var branch1 = new ColleagueB(m, "David");
        var 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");
    }