Esempio n. 1
0
    //---------------------
    // 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;
        }
    }
Esempio n. 2
0
    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;
            }
        }
    }