Exemplo n.º 1
0
        public VoidMethodObjectSourceProxy(object source, MethodInfo methodInfo) : base(source)
        {
            if (!methodInfo.ReturnType.Equals(typeof(void)))
            {
                throw new ArgumentException("methodInfo");
            }

            this.invoker = methodInfo.AsProxy(source);
        }
        public MethodTargetProxy(object target, IProxyMethodInfo methodInfo) : base(target)
        {
            this.methodInfo = methodInfo;
            if (!methodInfo.ReturnType.Equals(typeof(void)))
            {
                throw new ArgumentException("methodInfo");
            }

            this.invoker = new WeakProxyInvoker(new WeakReference(target, true), methodInfo);
        }
 protected override void Dispose(bool disposing)
 {
     if (!disposed)
     {
         this.UnbindEvent();
         this.handler       = null;
         this.scriptInvoker = null;
         this.invoker       = null;
         disposed           = true;
         base.Dispose(disposing);
     }
 }
Exemplo n.º 4
0
        public VoidMethodTargetProxy(object target, MethodInfo methodInfo)
        {
            if (!methodInfo.ReturnType.Equals(typeof(void)))
            {
                throw new ArgumentException("methodInfo");
            }

            if (target != null)
            {
                this.target = new WeakReference(target, true);
            }

            this.invoker = methodInfo.AsProxy(target);
        }
Exemplo n.º 5
0
        protected virtual bool IsValid(IProxyInvoker invoker)
        {
            IProxyMethodInfo info = invoker.ProxyMethodInfo;

            if (!info.ReturnType.Equals(typeof(void)))
            {
                return(false);
            }

            ParameterInfo[] parameters = info.Parameters;
            // if (parameters == null || parameters.Length != 2)
            return(false);

            // return parameters[0].ParameterType.IsAssignableFrom(typeof(object)) && parameters[1].ParameterType.IsAssignableFrom(typeof(InteractionEventArgs));
        }
Exemplo n.º 6
0
        protected override bool IsValid(IProxyInvoker invoker)
        {
            MethodInfo info = invoker.ProxyMethodInfo.MethodInfo;

            if (!info.ReturnType.Equals(typeof(void)))
            {
                return(false);
            }

            List <Type> parameterTypes = info.GetParameterTypes();

            if (parameterTypes.Count != 0)
            {
                return(false);
            }
            return(true);
        }
        protected override bool IsValid(IProxyInvoker invoker)
        {
            IProxyMethodInfo info = invoker.ProxyMethodInfo;

            if (!info.ReturnType.Equals(typeof(void)))
            {
                return(false);
            }

            var parameters = info.Parameters;

            if (parameters != null && parameters.Length != 0)
            {
                return(false);
            }
            return(true);
        }
        protected virtual bool IsValid(IProxyInvoker invoker)
        {
            IProxyMethodInfo info = invoker.ProxyMethodInfo;

            if (!info.ReturnType.Equals(typeof(void)))
            {
                return(false);
            }

            var parameters = info.Parameters;

            if (parameters == null || parameters.Length != 1)
            {
                return(false);
            }

            return(parameters[0].ParameterType.IsAssignableFrom(typeof(T)));
        }
Exemplo n.º 9
0
        protected virtual bool IsValid(IProxyInvoker invoker)
        {
            MethodInfo info = invoker.ProxyMethodInfo.MethodInfo;

            if (!info.ReturnType.Equals(typeof(void)))
            {
                return(false);
            }

            List <Type> parameterTypes = info.GetParameterTypes();

            if (parameterTypes.Count != 2)
            {
                return(false);
            }

            return(parameterTypes[0].IsAssignableFrom(typeof(object)) && parameterTypes[1].IsAssignableFrom(typeof(InteractionEventArgs)));
        }
        public ParameterWrapProxyInvoker(IProxyInvoker invoker, object commandParameter)
        {
            if (invoker == null)
            {
                throw new ArgumentNullException("invoker");
            }
            if (commandParameter == null)
            {
                throw new ArgumentNullException("commandParameter");
            }

            this.invoker          = invoker;
            this.commandParameter = commandParameter;

            if (!IsValid(invoker))
            {
                throw new ArgumentException("Bind method failed.the parameter types do not match.");
            }
        }
Exemplo n.º 11
0
 public MethodNodeProxy(object source, IProxyMethodInfo methodInfo) : base(source)
 {
     this.methodInfo = methodInfo;
     this.invoker    = new ProxyInvoker(this.source, this.methodInfo);
 }
        public virtual void SetValue(object value)
        {
            if (value != null && !(value is IProxyInvoker || value is Delegate || value is IScriptInvoker))
            {
                throw new ArgumentException("Binding object to InteractionRequest failed, unsupported object type", "value");
            }

            if (this.invoker != null)
            {
                this.invoker = null;
            }

            if (this.handler != null)
            {
                this.handler = null;
            }

            if (this.scriptInvoker != null)
            {
                this.scriptInvoker = null;
            }

            if (value == null)
            {
                return;
            }

            //Bind Method
            IProxyInvoker invoker = value as IProxyInvoker;

            if (invoker != null)
            {
                if (this.IsValid(invoker))
                {
                    this.invoker = invoker;
                    return;
                }

                throw new ArgumentException("Binding the IProxyInvoker to InteractionRequest failed, mismatched parameter type.");
            }

            //Bind Delegate
            Delegate handler = value as Delegate;

            if (handler != null)
            {
                if (this.IsValid(handler))
                {
                    this.handler = handler;
                    return;
                }

                throw new ArgumentException("Binding the Delegate to InteractionRequest failed, mismatched parameter type.");
            }

            //Bind Script Function
            IScriptInvoker scriptInvoker = value as IScriptInvoker;

            if (scriptInvoker != null)
            {
                this.scriptInvoker = scriptInvoker;
            }
        }
        public override void SetValue(object value)
        {
            var target = this.Target;

            if (target == null)
            {
                return;
            }

            if (this.command != null)
            {
                UnbindCommand(this.command);
                this.command = null;
            }

            if (this.invoker != null)
            {
                this.invoker = null;
            }

            if (this.handler != null)
            {
                this.handler = null;
            }

            if (value == null)
            {
                return;
            }

            //Bind Command
            ICommand command = value as ICommand;

            if (command != null)
            {
                this.command = command;
                BindCommand(this.command);
                UpdateTargetEnable();
                return;
            }

            //Bind Method
            IProxyInvoker proxyInvoker = value as IProxyInvoker;

            if (proxyInvoker != null)
            {
                if (this.IsValid(proxyInvoker))
                {
                    this.invoker = proxyInvoker;
                    return;
                }

                throw new ArgumentException("Bind method failed.the parameter types do not match.");
            }

            //Bind Delegate
            Delegate handler = value as Delegate;

            if (handler != null)
            {
                if (this.IsValid(handler))
                {
                    this.handler = handler;
                    return;
                }

                throw new ArgumentException("Bind method failed.the parameter types do not match.");
            }

            //Bind Script Function
            IInvoker invoker = value as IInvoker;

            if (invoker != null)
            {
                this.invoker = invoker;
            }
        }
 protected abstract bool IsValid(IProxyInvoker invoker);
        public virtual void SetValue(object value)
        {
            try
            {
                if (this.invoker != null)
                {
                    this.invoker = null;
                }

                if (this.handler != null)
                {
                    this.handler = null;
                }

                if (this.scriptInvoker != null)
                {
                    this.scriptInvoker = null;
                }

                if (value == null)
                {
                    return;
                }

                //Bind Method
                IProxyInvoker invoker = value as IProxyInvoker;
                if (invoker != null)
                {
                    if (this.IsValid(invoker))
                    {
                        this.invoker = invoker;
                        return;
                    }

                    throw new ArgumentException("Bind method failed.the parameter types do not match.");
                }

                //Bind Delegate
                Delegate handler = value as Delegate;
                if (handler != null)
                {
                    if (this.IsValid(handler))
                    {
                        this.handler = handler;
                        return;
                    }

                    throw new ArgumentException("Bind method failed.the parameter types do not match.");
                }

                //Bind Script Function
                IScriptInvoker scriptInvoker = value as IScriptInvoker;
                if (scriptInvoker != null)
                {
                    this.scriptInvoker = scriptInvoker;
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("SetValue failed with exception,{0}", e);
                }
            }
        }
Exemplo n.º 16
0
 public RuntimeRouteBuilder(IProxyInvoker proxyInvoker)
 {
     Contracts.CheckValue(proxyInvoker, nameof(proxyInvoker));
     _proxyInvoker = proxyInvoker;
 }
        public override void SetValue(object value)
        {
            var target = this.Target;

            if (target == null)
            {
                return;
            }

            if (this.command != null)
            {
                UnbindCommand(this.command);
                this.command = null;
            }

            if (this.invoker != null)
            {
                this.invoker = null;
            }

            if (this.handler != null)
            {
                this.handler = null;
            }

            if (this.scriptInvoker != null)
            {
                this.scriptInvoker = null;
            }

            if (value == null)
            {
                return;
            }

            //Bind Command
            ICommand command = value as ICommand;

            if (command != null)
            {
                if (this.interactable == null)
                {
                    var interactablePropertyInfo = target.GetType().GetProperty("interactable");
                    if (interactablePropertyInfo != null)
                    {
                        this.interactable = interactablePropertyInfo.AsProxy();
                    }
                }

                this.command = command;
                BindCommand(this.command);
                UpdateTargetInteractable();
                return;
            }

            //Bind Method
            IProxyInvoker invoker = value as IProxyInvoker;

            if (invoker != null)
            {
                if (this.IsValid(invoker))
                {
                    this.invoker = invoker;
                    return;
                }

                throw new ArgumentException("Bind method failed.the parameter types do not match.");
            }

            //Bind Delegate
            Delegate handler = value as Delegate;

            if (handler != null)
            {
                if (this.IsValid(handler))
                {
                    this.handler = handler;
                    return;
                }

                throw new ArgumentException("Bind method failed.the parameter types do not match.");
            }

            //Bind Script Function
            IScriptInvoker scriptInvoker = value as IScriptInvoker;

            if (scriptInvoker != null)
            {
                this.scriptInvoker = scriptInvoker;
            }
        }