Пример #1
0
    public void Set(string _name, Delegate _handler, IEventDispatcher _sender, string _extendInfo = null)
    {
        name           = _name;
        extendInfo     = _extendInfo;
        voidHandler    = null;
        normalHandler  = null;
        moduleHandler  = null;
        dynamicHandler = null;
        m_handler      = null;
        m_paramType    = null;
        sender         = _sender;

        var ps = _handler.Method.GetParameters();

        if (ps.Length == 0)
        {
            voidHandler = _handler as VoidHandler;
            m_handler   = voidHandler;
        }
        else if (ps.Length > 1)
        {
            Logger.LogError("Event handler can only have one parameter. handler:{0}", _handler.Method);
            return;
        }
        else if (ps[0].ParameterType.IsSubclassOf(typeof(ModuleEvent)))
        {
            moduleHandler = _handler;
            m_paramType   = ps[0].ParameterType;
            m_handler     = moduleHandler;
        }
        else if (ps[0].ParameterType == Event_.defaultType)
        {
            normalHandler = _handler as NormalHandler;
            m_paramType   = Event_.defaultType;
            m_handler     = normalHandler;
        }
        else
        {
            dynamicHandler = _handler;
            m_paramType    = ps[0].ParameterType;
            m_handler      = dynamicHandler;
        }
    }
Пример #2
0
 public EventListener AddEventListener(string name, NormalHandler handler)
 {
     return(_AddEventListener(name, handler));
 }
Пример #3
0
 public void RemoveEventListener(string name, NormalHandler handler)
 {
     _RemoveEventListener(name, handler);
 }