public AddObserver ( System action ) : void | ||
action | System | |
Результат | void |
public void AddObserver(string notificationName, System.Action action) { //if there is already an existing key, add the listener to the observer list if(this.eventObservers.ContainsKey(notificationName)) { ObserverList eventObserver = this.eventObservers[notificationName]; eventObserver.AddObserver(action); } //create a new instance of an observer list else { ObserverList eventObserver = new ObserverList(); eventObserver.AddObserver(action); this.eventObservers.Add(notificationName,eventObserver); } }
/// <summary> /// Adds an observer to listen to specified by notification name. Action has no parameters. /// </summary> public void AddObserver(string notificationName, System.Action action) { //if there is already an existing key, add the listener to the observer list if (this.eventObservers.ContainsKey(notificationName)) { ObserverList eventObserver = this.eventObservers[notificationName]; eventObserver.AddObserver(action); } //create a new instance of an observer list else { ObserverList eventObserver = new ObserverList(); eventObserver.AddObserver(action); this.eventObservers.Add(notificationName, eventObserver); } }