// 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); } }
void Test() { mediator = new ConcreteMediator(); colleague1 = new ConcreteColleague1(mediator); colleague2 = new ConcreteColleague2(mediator); mediator.Colleague1 = colleague1; mediator.Colleague2 = colleague2; colleague1.Send("同志们好!"); colleague2.Send("首长好!"); }
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); } }
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"); }
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); }
public override void Send(string message, Colleague colleague) { this.Colleagues.Where(c => c != colleague).ToList().ForEach(c => c.HandleNotification(message)); }
public void Register(Colleague colleague) { colleague.RegisterMediator(this); this.Colleagues.Add(colleague); }
public abstract void SendMessage(Colleague theColleague, string Message);
public void addColleague(Colleague colleague) { colleagues.Add(colleague); }
public void AddColleague(Colleague colleague) { this.colleagues.Add(colleague); colleagueCodes += 1; colleague.SetCode(colleagueCodes); }
public abstract void Send(string message, Colleague colleague);
public Mediator(ColleagueA colleagueA, ColleagueB colleagueB) { this.ColleagueA = colleagueA; this.ColleagueB = colleagueB; }
public void AddColleague(Colleague newColleague) { colleagues.Add(newColleague); colleagueCodes++; newColleague.SetCollCode(colleagueCodes); }
public abstract void Send(string msg, Colleague colleague);