//--------------------- // Register and Unregister //--------------------- public void Register <T>(MP4_Event.Handler handler) where T : MP4_Event { Type type = typeof(T); if (registeredHandlers.ContainsKey(type)) { registeredHandlers[type] += handler; } else { registeredHandlers[type] = handler; } }
public void Unregister <T>(MP4_Event.Handler handler) where T : MP4_Event { Type type = typeof(T); MP4_Event.Handler handlers; if (registeredHandlers.TryGetValue(type, out handlers)) { handlers -= handler; if (handlers == null) { registeredHandlers.Remove(type); } else { registeredHandlers[type] = handlers; } } }