public void Register <T>(BeatEvent.Handler handler) where T : BeatEvent { System.Type type = typeof(T); if (registered_handlers.ContainsKey(type)) { if (!IsEventHandlerRegistered(type, handler)) { registered_handlers[type] += handler; } } else { registered_handlers.Add(type, handler); } }
public void Unregister <T>(BeatEvent.Handler handler) where T : BeatEvent { System.Type type = typeof(T); BeatEvent.Handler handlers; if (registered_handlers.TryGetValue(type, out handlers)) { handlers -= handler; if (handlers == null) { registered_handlers.Remove(type); } else { registered_handlers[type] = handlers; } } }