public void SendSms(object sender, AccountEventArgs e) { AccountEvent acount = (AccountEvent)sender; Console.WriteLine("短信提醒您{0}先生,您账户发生取钱:{1},现在余额:{2}。【{3}】", acount.accountName, e.updatemoney, acount.accountmoney, acount.bankName); }
public static void Test() { AccountEvent he = new AccountEvent("小何"); SmsNotify sms = new SmsNotify(); WeChatNotify wechat = new WeChatNotify(); EmailNotify email = new EmailNotify(); he.NotifyHandler += sms.NotifySms; he.NotifyHandler += wechat.NotifyWeChat; ; he.NotifyHandler += email.NotifyEmail; he.Notify(); }
public static void Test() { AccountEvent he = new AccountEvent(10000, "小何"); Email email = new Email(); Sms sms = new Sms(); he.Notify += email.SendEmail; he.Notify += email.SendEmail; he.Notify += sms.SendSms; he.Update(1000); he.Update(4000); AccountEvent he1 = new AccountEvent(100000, "小"); he1.Notify += sms.SendSms; he1.Update(1000); Console.ReadLine(); }