private static void Main(string[] args) { Intermediary zhiLian = new Intermediary("智联招聘"); Intermediary _51Job = new Intermediary("51Job"); Intermediary xinsj = new Intermediary("新世纪人才网"); JobSeeker zhangSan = new JobSeeker("张三"); JobSeeker liSi = new JobSeeker("李四"); zhangSan.Register(zhiLian); zhangSan.Register(_51Job); liSi.Register(xinsj); zhiLian.ReceiveNewJobMessage("文思海辉招收测试人员"); xinsj.ReceiveNewJobMessage("NIIT招收DotNet讲师"); Console.WriteLine("三个月后....."); zhangSan.UnRegister(zhiLian); zhangSan.UnRegister(_51Job); liSi.UnRegister(xinsj); zhiLian.ReceiveNewJobMessage("微软中国招收客服人员"); Console.ReadLine(); }
private void intermediary_OnNewJobReceive(object sender, NewJobMessageEventArgs e) { Intermediary intermediary = sender as Intermediary; Console.WriteLine("{0}求职者从{1}中介获取到了{2}工作信息", Name, intermediary.Name, e.Message); }
public void UnRegister(Intermediary intermediary) { intermediary.OnNewJobReceive -= intermediary_OnNewJobReceive; Console.WriteLine("{0}从{1}中介退订了", Name, intermediary.Name); }
public void Register(Intermediary intermediary) { intermediary.OnNewJobReceive += intermediary_OnNewJobReceive; Console.WriteLine("{0}到{1}中介去注册了", Name, intermediary.Name); }