예제 #1
0
 public void ReleaseModule(BaseBizModule module)
 {
     if (module != null)
     {
         if (mModulesMap.ContainsKey(module.Name))
         {
             mModulesMap.Remove(module.Name);
             module.Release();
         }
         else
         {
         }
     }
 }
예제 #2
0
        public ModuleEvent Event(string target, string type)
        {
            ModuleEvent   moduleEvent = null;
            BaseBizModule module      = GetModule(target);

            if (module != null)
            {
                moduleEvent = module.Event(type);
            }
            else
            {
                EventTable table = GetPreListenEventTable(target);
                moduleEvent = table.GetEvent(type);
            }
            return(moduleEvent);
        }
예제 #3
0
        public void SendMessage(string target, string msg, params object[] args)
        {
            BaseBizModule module = GetModule(target);

            if (module != null)
            {
                module.HandleMessage(msg, args);
            }
            else
            {
                List <MessageObject> list          = GetCacheMessagelist(target);
                MessageObject        messageObject = new MessageObject();
                messageObject.target = target;
                messageObject.msg    = msg;
                messageObject.args   = args;
                list.Add(messageObject);
            }
        }
예제 #4
0
        public BaseBizModule CreateModule(string name, object args = null)
        {
            if (mModulesMap.ContainsKey(name))
            {
                return(null);
            }

            BaseBizModule module = null;
            Type          type   = Type.GetType(mDomain + "." + name);

            if (type != null)
            {
                module = Activator.CreateInstance(type) as BaseBizModule;
            }
            else
            {
                module = new LuaModule(name);
            }
            mModulesMap.Add(name, module);

            //
            if (mPreListenerEventsMap.ContainsKey(name))
            {
                EventTable eventTable = mPreListenerEventsMap[name];
                mPreListenerEventsMap.Remove(name);
                module.SetEventTable(eventTable);
            }
            module.Create(args);

            //
            if (mMessageCacheMap.ContainsKey(name))
            {
                List <MessageObject> list = mMessageCacheMap[name];
                foreach (var messageObject in list)
                {
                    module.HandleMessage(messageObject.msg, messageObject.args);
                }
                mMessageCacheMap.Remove(name);
            }
            return(module);
        }