Example #1
0
    public void Register <T>(Event.Handler handler) where T : Event
    {
        Type type = typeof(T);

        if (RegisteredHandlers.ContainsKey(type))
        {
            RegisteredHandlers[type] += handler;
        }
        else
        {
            RegisteredHandlers[type] = handler;
        }
    }
Example #2
0
    public void UnRegister <T>(Event.Handler handler) where T : Event
    {
        Type type = typeof(T);

        Event.Handler handlers;

        if (RegisteredHandlers.TryGetValue(type, out handlers))
        {
            handlers -= handler;
            if (handlers == null)
            {
                RegisteredHandlers.Remove(type);
            }
            else
            {
                RegisteredHandlers[type] = handlers;
            }
        }
    }