예제 #1
0
        public override void Send(string message,
                                  Colleague colleague)
        {
            if (colleague == _colleague1)
            {
                _colleague2.Notify(message);
            }
            else

            {
                _colleague1.Notify(message);
            }
        }
 public override void Send(string message, Colleague colleague)
 {
     //if (colleague == Colleague1)
     //{
     //    Colleague2.HandleNotification(message);
     //}
     //else
     //{
     //    Colleague1.HandleNotification(message);
     //}
     colleagues.Where(x => x != colleague).ToList()
     .ForEach(c => c.HandleNotification(message));
 }
예제 #3
0
 public abstract void Send(string message,
                           Colleague colleague);
예제 #4
0
        protected List <Colleague> colleagues = new List <Colleague>(); // 用于存储同事对象

        public void Register(Colleague colleague)
        {
            colleagues.Add(colleague);
        }
 public void Register(Colleague colleague)
 {
     // bi-directional references:
     colleague.SetMediator(this);
     this.colleagues.Add(colleague);
 }