コード例 #1
0
    public void FireEvent <H> (IEvent <H> p_event)
        where H : class, IHandler
    {
        List <Pair <IHandler, bool> > list;

        // ------------------- DECLARE -------------------- //

        list = null;
        // --------------------- INIT --------------------- //

        if (m_handlers.ContainsKey(p_event.GetEventType()) == false)
        {
            if (p_event.GetEventType().Equals(EventHandlerHasBeenDestroyed.TYPE))
            {
                p_event.Dispatch(this as H);
            }
            return;
        }

        m_stack_depth += 1;
        list           = m_handlers [p_event.GetEventType()];

        // Dispatch event among handler.
        foreach (var handler in list)
        {
            if (!handler.Value)
            {
                H _handler = handler.Key as H;
                p_event.Dispatch(_handler);
            }
        }

        m_stack_depth -= 1;

        CleanUpRemovedHandlers();
    }