public void Notify(ObserverEvent e) { if (Update != null) { Update(e); } }
static void Main(string[] args) { ObserverEvent e = new ObserverEvent(); e.SubjectState = "TOM猫来了"; Tom cat = new Tom(); Jerry jerry = new Jerry("JERRY"); cat.Update += jerry.Message; cat.Notify(e); }
public void Message(ObserverEvent e) { System.Console.WriteLine($"{e.SubjectState},{_name}快跑"); }