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