/// <summary> /// 取消注册事件处理程序 /// </summary> /// <param name="eventHandler">事件处理程序</param> public void DeRegister(MessageBusEventHandler eventHandler) { if (EventHandlers.Contains(eventHandler)) { EventHandlers.Remove(eventHandler); } }
/// <summary> /// Gets the <see cref="System.Collections.ICollection"/> of /// <see cref="Spring.Objects.IEventHandlerValue"/>s for the supplied /// event name. /// </summary> public ICollection this [string eventName] { get { return(EventHandlers.Contains(eventName) ? EventHandlers [eventName] as ICollection : EventValues.EmptyHandlers); } }
public void AddEventHandler(IEventHandler handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } lock (Sync) if (!EventHandlers.Contains(handler)) { EventHandlers.Add(handler); } }
/// <summary> /// 注册指定的事件处理程序 /// </summary> /// <param name="eventHandler">事件处理程序</param> public void Register(MessageBusEventHandler eventHandler) { if (eventHandler == null) { return; } if (!EventHandlers.Contains(eventHandler)) { EventHandlers.Add(eventHandler); } }