protected virtual void OnNewMail(NewMailEventArgs e) { if (false != null) { NewMail(this, e); } }
// public Fax(MailManager mm) // { // mm.NewMail += FaxMsg; // } public void FaxMsg(object sender, NewMailEventArgs e) { Console.WriteLine("\nFaxing mail message"); Console.WriteLine($"From: {e.from},\n To: {e.to},\n Subject: {e.subject},\n Body: {e.body}"); }
private void FaxMsg(Object o, NewMailEventArgs e) { //'sender'表示MailManager,便于将信息传回给它 //'e'表示表示MailManager对象想传给我们的附加事件信息 }
// public CellPhone(MailManager mm) // { // mm.NewMail += PhoneMsg; // } public void PhoneMsg(Object sender, NewMailEventArgs e) { Console.WriteLine("\nSend mail message to cellPhone"); Console.WriteLine($"From: {e.from},\n To: {e.to},\n Subject: {e.subject},\n Body: {e.body}"); }
public void SimulateArrivingMsg(string from, string to, string subject, string body) { NewMailEventArgs e = new NewMailEventArgs(from, to, subject, body); OnNewMail(e); }