/// <summary> /// Remove an event handler from the system. /// It's important to make sure all event handler are removed when they are disposed of. /// Event handlers left in the system, will cause memory leaks, or errors. /// </summary> /// <param name="catagory"></param> /// <param name="subcatagory"></param> /// <param name="eventHandler"></param> public static void RemoveEventHandler(Enum catagory, Enum subcatagory, ICEventHandler eventHandler) { var handlerList = GetHandlerList(catagory, subcatagory); if (handlerList != null) { handlerList.Remove(eventHandler); } }
/// <summary> /// Add a new event handler to the system /// Once the handler is added, it will recieve all events which are boradcasted on the system. /// If the object has already been registered in this list, this class will trhow an error. /// </summary> /// <param name="catagory"></param> /// <param name="subcatagory"></param> /// <param name="eventHandler"></param> public static void AddEventHandler(Enum catagory, Enum subcatagory, ICEventHandler eventHandler) { var handlerList = GetHandlerList(catagory, subcatagory, true); if (handlerList.Contains(eventHandler)) { throw new System.Exception("The event handler is already in this catagory in the event system"); } handlerList.Add(eventHandler); }