Example #1
0
 protected virtual void NotifierChanged(object sender, StateEventArgs args) // Template method pattern
 {
     if (args != null && !String.IsNullOrEmpty(args.Message))
     {
         // Locate subscription
         var subscription = _subscriptions.FirstOrDefault(s => s.Notifier == (IStateEventNotifier)sender);
         if (subscription != null)
         {
             EventOccured(subscription, args);
         }
     }
 }
 // Template method pattern
 protected virtual void NotifierChanged(object sender, StateEventArgs args)
 {
     if (args != null && !String.IsNullOrEmpty(args.Message))
     {
         // Locate subscription
         var subscription = _subscriptions.FirstOrDefault(s => s.Notifier == (IStateEventNotifier)sender);
         if (subscription != null)
         {
             EventOccured(subscription, args);
         }
     }
 }
Example #3
0
 protected abstract void EventOccured(StateEventSubscription s, StateEventArgs args);
 protected override void EventOccured(StateEventSubscription s, StateEventArgs args)
 {
     Console.WriteLine(String.Format("{0} - {1}", s.Subscriber.GetEventOccured().ToShortTimeString(), args.Message));
 }
 protected override void EventOccured(StateEventSubscription s, StateEventArgs args)
 {
     File.AppendAllText(_filePath, String.Format("{0} - {1}",
         s.Subscriber.GetEventOccured().ToShortTimeString(), args.Message) + Environment.NewLine);
 }
Example #6
0
 protected virtual void OnChanged(string message)
 {
     StateEventHandler handler = Changed;
     if (handler != null)
     {
         var args = new StateEventArgs() { Message = message };
         handler(this, args);
     }
 }
 protected abstract void EventOccured(StateEventSubscription s, StateEventArgs args);