Exemplo n.º 1
0
    public void AddCallbackListener(string eventType, EVENT_DELEGATE listener)
    {
        Delegate d = null;

        if (mDelegates.TryGetValue(eventType, out d))
        {
            mDelegates[eventType] = Delegate.Combine(d, listener);
        }
        else
        {
            mDelegates[eventType] = listener;
        }
    }
Exemplo n.º 2
0
    public bool SendCallbackEvent(string eventType)
    {
        Delegate d = null;

        if (mDelegates.TryGetValue(eventType, out d))
        {
            EVENT_DELEGATE callback = d as EVENT_DELEGATE;
            if (callback != null)
            {
                return(callback());
            }
        }
        return(false);
    }
Exemplo n.º 3
0
    public void RemoveCallbackListener(string eventType, EVENT_DELEGATE listener)
    {
        Delegate d = null;

        if (mDelegates.TryGetValue(eventType, out d))
        {
            Delegate currentDel = Delegate.Remove(d, listener);

            if (currentDel == null)
            {
                mDelegates.Remove(eventType);
            }
            else
            {
                mDelegates[eventType] = currentDel;
            }
        }
    }
Exemplo n.º 4
0
    public bool SendCallbackEvent <T>(string eventType, T arg)
    {
        if (arg == null)
        {
            throw new ArgumentNullException("arg");
        }
        Delegate d = null;

        if (mDelegates.TryGetValue(eventType, out d))
        {
            EVENT_DELEGATE <T> callback = d as EVENT_DELEGATE <T>;
            if (callback != null)
            {
                return(callback(arg));
            }
        }
        return(false);
    }