コード例 #1
0
 public override void Release()
 {
     base.Release();
     if (m_tblEvent != null)
     {
         m_tblEvent.UnBindAll();
         m_tblEvent = null;
     }
 }
コード例 #2
0
 internal void SetEventTable(EventTable eventTable)
 {
     if (eventTable != null)
     {
         m_tblEvent = eventTable;
     }
     else
     {
         m_tblEvent = new EventTable();
     }
 }
コード例 #3
0
        /// <summary>
        /// 通过反射创建业务模块
        /// </summary>
        public BusinessModule CreateModule(string name, object arg = null)
        {
            if (m_mapModules.ContainsKey(name))
            {
                LogMgr.LogWarning("The Module<{0}> Has Existed!", name);
                return(null);
            }

            BusinessModule module = null;
            Type           type   = Type.GetType(m_domain + "." + name);

            if (type != null)
            {
                module = Activator.CreateInstance(type) as BusinessModule;
            }
            else
            {
                module = new LuaModule(name);
                LogMgr.LogWarning("The Module<{0}> Is LuaModule!", name);
            }
            m_mapModules.Add(name, module);

            //处理预监听的事件
            EventTable eventTable = null;

            if (m_mapPreListenEvents.ContainsKey(name))
            {
                eventTable = m_mapPreListenEvents[name];
                m_mapPreListenEvents.Remove(name);
            }
            module.SetEventTable(eventTable);

            module.Create(arg);

            //处理缓存的消息
            if (m_mapCacheMessage.ContainsKey(name))
            {
                List <MessageObject> messageList = m_mapCacheMessage[name];
                foreach (MessageObject item in messageList)
                {
                    if (item.isCall)
                    {
                        module.CallMethod(item.msg, item.args);
                    }
                    else
                    {
                        module.HandleMessage(item.msg, item.args);
                    }
                }
                m_mapCacheMessage.Remove(name);
            }
            return(module);
        }
コード例 #4
0
        private EventTable GetPreEventTable(string target)
        {
            EventTable table = null;

            if (!m_mapPreListenEvents.ContainsKey(target))
            {
                table = new EventTable();
                m_mapPreListenEvents.Add(target, table);
            }
            else
            {
                table = m_mapPreListenEvents[target];
            }
            return(table);
        }