Пример #1
0
        static void Main(string[] args)
        {
            NotifyObject staff1 = new NotifyObject("seasun");
            NotifyObject staff2 = new NotifyObject("dong");
            Observer miss = new Observer(3);
            miss.Subscribe(staff1);
            miss.Subscribe(staff2);

            Console.Read();
        }
Пример #2
0
 /// <summary>
 /// 快來孝敬過我,老闆回來我第一時間通知你們
 /// </summary>
 /// <param name="notifyObj">孝敬我的對象</param>
 public void Subscribe(NotifyObject notifyObj)
 {
     boss.notify += notifyObj.Receive;//我要通知所有之前有孝敬過我的同事
 }