public object GetObject(string scriptType, string scripToken, string singletonToken)
        {
            object tmp = null;

            if (objectDictionary.ContainsKey(scriptType))
            {
                if (objectDictionary[scriptType].ContainsKey(singletonToken))
                {
                    tmp = objectDictionary[scriptType][singletonToken];
                }
                else
                {
                    tmp = FrameManager.CreateInstence(scriptType, scripToken);
                    objectDictionary[scriptType].Add(singletonToken, tmp);
                }
            }
            else
            {
                tmp = FrameManager.CreateInstence(scriptType, scripToken);
                objectDictionary.Add(scriptType, new Dictionary <string, object>()
                {
                    { singletonToken, tmp }
                });
            }
            return(tmp);
        }
Beispiel #2
0
 public void SendMsg(MessageArgs msg, string handler, object[] parameters)//发送消息方法
 {
     //msg.Source = notifiedObject;
     if (!MsgHandlers.ContainsKey(handler))
     {
         MsgHandlers.Add(handler, FrameManager.CreateInstence <IMsgHandler>(handler, null));
     }
     MsgHandlers[handler].StartOperation(msg, parameters);
 }
Beispiel #3
0
 public void RegistMsg(string msg, MsgEventHandler handlerEvent, string handler = AppConst.MsgHandler_Common)
 {
     if (!MsgHandlers.ContainsKey(handler))
     {
         MsgHandlers.Add(handler, FrameManager.CreateInstence <IMsgHandler>(handler, null));
     }
     if (MsgHandlers[handler].MsgEventHandlers.ContainsKey(msg))
     {
         MsgHandlers[handler].MsgEventHandlers[msg] = handlerEvent;
     }
     else
     {
         MsgHandlers[handler].MsgEventHandlers.Add(msg, handlerEvent);
     }
     FrameManager.GetInstence <MsgManager>(notifiedObject.MsgStstem).RegistMsg(this, msg);
 }
        public void Initialization(object initializedObject)
        {
            INotifiedObject notifiedObject = initializedObject as INotifiedObject;
            IMsgComponent   component      = FrameManager.CreateInstence <IMsgComponent>();

            component.notifiedObject = notifiedObject;
            component.MsgHandlers    = new Dictionary <string, IMsgHandler>();

            notifiedObject.SendMsg     = (msg, handler, parameters) => { component.SendMsg(msg, handler, parameters); };
            notifiedObject.RegistMsg   = (msg, handlerEvent, handler) => { component.RegistMsg(msg, handlerEvent, handler); };
            notifiedObject.UnRegistMsg = (msg) => { component.UnRegistMsg(msg); };

            foreach (MethodInfo method in notifiedObject.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(p => p.IsDefined(typeof(MsgBindingAttribute), true)))
            {
                MsgBindingAttribute attribute = method.GetCustomAttribute(typeof(MsgBindingAttribute)) as MsgBindingAttribute;
                component.RegistMsg(attribute.MsgToken, Delegate.CreateDelegate(typeof(MsgEventHandler), initializedObject, method) as MsgEventHandler, attribute.TargetHandler);
            }
        }
Beispiel #5
0
        public void Initialization(object initializedObject)
        {
            MonoBehaviour targetObject = (MonoBehaviour)initializedObject;

            foreach (GameObject g in targetObject.gameObject.GetInsideUI())
            {
                IUINode uiNode = g.GetComponent <IUINode>();
                if (uiNode != null)
                {
                    UIBindingComponent[] components = g.GetComponents <UIBindingComponent>();
                    foreach (UIBehaviour ui in g.GetComponents <UIBehaviour>())
                    {
                        UIBindingComponent[] targetBindingComponent = components.Where(p => p.targetComponent == ui.GetType().Name).ToArray();
                        if (targetBindingComponent.Length > 0)
                        {
                            FrameManager.CreateInstence <IUIBinder>(ui.GetType().Name).Binding(ui, targetBindingComponent.First(), targetObject as IUILogicalNode);
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public void ExecuteCommand(string commandName, params object[] parameters)
        {
            ICommand command = FrameManager.CreateInstence <ICommand>(id: commandName);

            command.Execute(parameters);
        }