/// <summary> /// Subscribes the listener to a its event. /// </summary> /// <param name="listener"> /// The listener object which knows what to subscribe to and the action to perform. /// </param> /// <param name="throwException">Should PluginException be thrown in case there is no such event.</param> /// <returns>True if subscription succeeded; otherwise - false.</returns> public bool Subscribe(ICherryEventListener listener, bool throwException = true) { ICherryEvent ce = null; if (this.events.TryGetValue(listener.ListenTo, out ce)) { return(ce.AddListener(listener)); } if (throwException) { throw new PluginException(string.Format("'{0}' event not found.", listener.ListenTo)); } else { return(false); } }
public bool AddListener(ICherryEventListener listener) { // will return false if such listener object already exist. return(this.listeners.Add(listener)); }
/// <summary> /// Subscribes the listener to a its event. /// </summary> /// <param name="listener"> /// The listener object which knows what to subscribe to and the action to perform. /// </param> /// <param name="throwException">Should PluginException be thrown in case there is no such event.</param> /// <returns>True if subscription succeeded; otherwise - false.</returns> public bool Subscribe(ICherryEventListener listener, bool throwException = true) { ICherryEvent ce = null; if (this.events.TryGetValue(listener.ListenTo, out ce)) { return ce.AddListener(listener); } if (throwException) { throw new PluginException(string.Format("'{0}' event not found.", listener.ListenTo)); } else { return false; } }
public bool AddListener(ICherryEventListener listener) { // will return false if such listener object already exist. return this.listeners.Add(listener); }