Exemplo n.º 1
0
 // Note this is a very simple implementation that would not
 // give you any additional benefit over Observer but
 // you could have some very complex notification logic here
 public void send(String message, Colleague originator)
 {
     //let all other screens know that this screen has changed
     foreach (Colleague colleague in colleagues)
     {
         //don't tell ourselves
         if (colleague != originator)
             colleague.receive(message);
     }
 }
Exemplo n.º 2
0
        void Test()
        {
            mediator = new ConcreteMediator();

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

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

            colleague1.Send("同志们好!");
            colleague2.Send("首长好!");
        }
Exemplo n.º 3
0
 public override void Send(string msg, Colleague colleague)
 {
     if (Customer == colleague)
     {
         Programmer.Notify(msg);
     }
     else if (Programmer == colleague)
     {
         Tester.Notify(msg);
     }
     else
     {
         Customer.Notify(msg);
     }
 }
Exemplo n.º 4
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");
        }
Exemplo n.º 5
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();
        }
 public override void Send(string message, Colleague colleague)
 {
     if (this.Customer == colleague)
     {
         // Customer is sedner
         // Programmer is receiver
         // Message to develop feature
         this.Programmer.Notify(message);
     }
     else if (this.Programmer == colleague)
     {
         // Programmer is sedner
         // Tester is receiver
         // Message to test feature
         this.Tester.Notify(message);
     }
     else if (this.Tester == colleague)
     {
         // Tester is sedner
         // Customer is receiver
         // Message that feature is complete
         this.Customer.Notify(message);
     }
 }
 public void AddColleague(Colleague colleague)
 {
     this.colleagues.Add (colleague);
     colleagueCodes += 1;
     colleague.SetCode(colleagueCodes);
 }
Exemplo n.º 8
0
 public override void Send(string message, Colleague colleague)
 {
     this.Colleagues.Where(c => c != colleague).ToList().ForEach(c => c.HandleNotification(message));
 }
Exemplo n.º 9
0
 public void Register(Colleague colleague)
 {
     colleague.RegisterMediator(this);
     this.Colleagues.Add(colleague);
 }
Exemplo n.º 10
0
 public abstract void SendMessage(Colleague theColleague, string Message);
Exemplo n.º 11
0
 public void addColleague(Colleague colleague)
 {
     colleagues.Add(colleague);
 }
Exemplo n.º 12
0
 public void AddColleague(Colleague colleague)
 {
     this.colleagues.Add(colleague);
     colleagueCodes += 1;
     colleague.SetCode(colleagueCodes);
 }
Exemplo n.º 13
0
 public abstract void Send(string message, Colleague colleague);
Exemplo n.º 14
0
 public Mediator(ColleagueA colleagueA, ColleagueB colleagueB)
 {
     this.ColleagueA = colleagueA;
     this.ColleagueB = colleagueB;
 }
Exemplo n.º 15
0
 public void addColleague(Colleague colleague)
 {
     colleagues.Add(colleague);
 }
Exemplo n.º 16
0
 public void AddColleague(Colleague newColleague)
 {
     colleagues.Add(newColleague);
     colleagueCodes++;
     newColleague.SetCollCode(colleagueCodes);
 }
Exemplo n.º 17
0
 public abstract void Send(string msg, Colleague colleague);