示例#1
0
 /// <summary>
 /// Removes the action at observer specified by notification name
 /// </summary>
 /// <param name="notificationName">Notification name.</param>
 /// <param name="action">Action.</param>
 public static void RemoveActionAtObserver(string notificationName, System.Action <Parameters> action)
 {
     if (eventObservers.ContainsKey(notificationName))
     {
         ObserverList eventObserver = eventObservers[notificationName];
         eventObserver.RemoveObserver(action);
     }
 }
示例#2
0
 /// <summary>
 /// Posts an event specified by name that does not require any parameters.
 /// Observers associated with this event will be called.
 /// </summary>
 public static void PostEvent(string notificationName)
 {
     if (eventObservers.ContainsKey(notificationName))
     {
         ObserverList eventObserver = eventObservers[notificationName];
         eventObserver.NotifyObservers();
     }
 }
示例#3
0
 public static void AddObserver(string notificationName, System.Action action)
 {
     //if there is already an existing key, add the listener to the observer list
     if (eventObservers.ContainsKey(notificationName))
     {
         ObserverList eventObserver = eventObservers[notificationName];
         eventObserver.AddObserver(action);
     }
     //create a new instance of an observer list
     else
     {
         ObserverList eventObserver = new ObserverList();
         eventObserver.AddObserver(action);
         eventObservers.Add(notificationName, eventObserver);
     }
 }