Ejemplo n.º 1
0
 public override void Release()
 {
     if (m_tblEvent != null)
     {
         m_tblEvent.Clear();
         m_tblEvent = null;
     }
     base.Release();
 }
Ejemplo n.º 2
0
        protected EventTable GetEventTable()
        {
            if (m_tblEvent == null)
            {
                m_tblEvent = new EventTable();
            }

            return(m_tblEvent);
        }
Ejemplo n.º 3
0
        private EventTable GetPreListenEventTable(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);
        }
Ejemplo n.º 4
0
        //====================================================
        public ModuleEvent Event(string target, string type)
        {
            ModuleEvent    evt    = null;
            BusinessModule module = GetModule(target);

            if (module != null)
            {
                module.Event(type);
            }
            else
            {
                EventTable table = GetPreListenEventTable(target);
                evt = table.GetEvent(type);
            }

            return(evt);
        }
Ejemplo n.º 5
0
        public BusinessModule CreateModule(string name, object args = null)
        {
            if (m_mapModules.ContainsKey(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);
            }
            m_mapModules.Add(name, module);

            //处理预监听的事件
            if (m_mapPreListenEvents.ContainsKey(name))
            {
                EventTable tblEvent = m_mapPreListenEvents[name];
                m_mapPreListenEvents.Remove(name);

                module.SetEventTable(tblEvent);
            }
            module.Create(args);

            //处理缓存的消息
            if (m_mapCacheMessage.ContainsKey(name))
            {
                List <MessageObject> list = m_mapCacheMessage[name];
                for (int i = 0; i < list.Count; i++)
                {
                    MessageObject msgobj = list[i];
                    module.HandleMessage(msgobj.msg, msgobj.args);
                }
                m_mapCacheMessage.Remove(name);
            }

            return(module);
        }
Ejemplo n.º 6
0
 internal void SetEventTable(EventTable tblEvnet)
 {
     m_tblEvent = tblEvnet;
 }