Exemple #1
0
        public virtual void Rebuild(GameObject gameObejct, List <DataBindingCall> bindingCalls)
        {
            var count = calls.Count;

            for (var i = 0; i < count; ++i)
            {
                var persistentCall = calls[i];
                var target         = persistentCall.target;
                if (gameObejct != (target is Component ? (target as Component).gameObject : target))
                {
                    Debug.LogError(string.Format("Target {0}.{1} is invalid!", target.name, persistentCall.methodName));
                    continue;
                }
                var methodInfo = ExpressionCall.FindMethod(target, persistentCall.methodName, persistentCall.modes);
                if (methodInfo == null)
                {
                    continue;
                }
                var bindingCall = new DataBindingCall(target, methodInfo, persistentCall.argument);
                if (!bindingCall.isVaild())
                {
                    continue;
                }
                bindingCalls.Add(bindingCall);
            }
        }
Exemple #2
0
        public void AddBinding(Object targetObj, string methodName, PersistentListenerMode[] modes, string argument)
        {
            var persistentCall = new ExpressionCall();

            persistentCall.target     = targetObj;
            persistentCall.methodName = methodName;
            persistentCall.modes      = modes;
            persistentCall.argument   = argument;
            calls.Add(persistentCall);
        }
Exemple #3
0
        public virtual void Rebuild(GameObject gameObejct, List <DataBindingCall> bindingCalls, List <DataModelCall> modelCalls, Dictionary <string, Object> modelTarget)
        {
            var count = calls.Count;

            for (var i = 0; i < count; ++i)
            {
                var persistentCall = calls[i];
                var target         = persistentCall.target;
                if (gameObejct != (target is Component ? (target as Component).gameObject : target))
                {
                    Debug.LogError(string.Format("Target {0}.{1} is invalid!", target.name, persistentCall.methodName));
                    continue;
                }
                if (string.IsNullOrEmpty(persistentCall.methodName))
                {
                    modelTarget.Add(persistentCall.argument, target);
                }
                else
                {
                    if (persistentCall.modes.Length != 0)
                    {
                        continue;
                    }
                    var setterMethodInfo = ExpressionCall.FindMethod(target, persistentCall.methodName, persistentCall.modes);
                    if (setterMethodInfo == null)
                    {
                        continue;
                    }
                    var getterMethodInfo = GetGetterMethodInfo(target, persistentCall.methodName);
                    if (getterMethodInfo == null)
                    {
                        continue;
                    }
                    var bindingCall = new DataBindingCall(target, setterMethodInfo, persistentCall.argument);
                    if (!bindingCall.isVaild())
                    {
                        continue;
                    }
                    bindingCalls.Add(bindingCall);
                    var call = new DataModelCall(target, getterMethodInfo, persistentCall.modes[0], persistentCall.argument);
                    modelCalls.Add(call);
                }
            }
        }