Example #1
0
 public void Notify(ObserverEvent e)
 {
     if (Update != null)
     {
         Update(e);
     }
 }
Example #2
0
        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);
        }
Example #3
0
 public void Message(ObserverEvent e)
 {
     System.Console.WriteLine($"{e.SubjectState},{_name}快跑");
 }