public LuaMethodTargetProxy(object target, LuaFunction function) : base(target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target", "Unable to bind to target as it's null");
            }

            this.invoker = new LuaInvoker(target, function);
        }
 protected override void Dispose(bool disposing)
 {
     if (!disposed)
     {
         this.UnbindEvent();
         this.handler       = null;
         this.scriptInvoker = null;
         this.invoker       = null;
         disposed           = true;
         base.Dispose(disposing);
     }
 }
Example #3
0
 public Finger()
 {
     isBusy        = false;
     cancelled     = false;
     this.dll      = Config.App.Peripheral["finger"].Value <string>("dll");
     this.timeout  = Config.App.Peripheral["finger"].Value <int>("timeout");
     this.enabled  = Config.App.Peripheral["finger"].Value <bool>("enabled");
     this.name     = Config.App.Peripheral["finger"].Value <string>("name");
     scriptInvoker = AutofacContainer.ResolveNamed <IScriptInvoker>("scriptInvoker");
     asyncCaller   = new RunAsyncCaller(Read);
     Initialize();
 }
Example #4
0
        public LuaMethodNodeProxy(LuaTable source, LuaFunction function) : base(source)
        {
            if (source == null)
            {
                throw new ArgumentException("source");
            }

            if (function == null)
            {
                throw new ArgumentException("function");
            }

            this.invoker = new LuaInvoker(source, function);
        }
Example #5
0
        public ParameterWrapScriptInvoker(IScriptInvoker invoker, object commandParameter)
        {
            if (invoker == null)
            {
                throw new ArgumentNullException("invoker");
            }
            if (commandParameter == null)
            {
                throw new ArgumentNullException("commandParameter");
            }

            this.invoker          = invoker;
            this.commandParameter = commandParameter;
        }
Example #6
0
 protected override void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             if (invoker != null && invoker is IDisposable)
             {
                 (invoker as IDisposable).Dispose();
                 invoker = null;
             }
         }
         disposed = true;
         base.Dispose(disposing);
     }
 }
Example #7
0
        public PeripheralManager()
        {
            scriptInvoker = AutofacContainer.ResolveNamed <IScriptInvoker>("scriptInvoker");
            //voicePlayer = AutofacContainer.ResolveNamed<IVoicePlayer>("voicePlayer");
            //magneticCardReaderWriter = AutofacContainer.ResolveNamed<IReader>("magneticCardReaderWriter");
            //icCardReaderWriter = AutofacContainer.ResolveNamed<IReader>("icCardReaderWriter");
            idCardReader = AutofacContainer.ResolveNamed <IReader>("idCardReader");
            //needlePrinter = AutofacContainer.ResolveNamed<IPrinter>("needlePrinter");
            thermalPrinter = AutofacContainer.ResolveNamed <IPrinter>("thermalPrinter");
            //evaluator = AutofacContainer.ResolveNamed<IEvaluator>("evaluator");
            //barScreen = AutofacContainer.ResolveNamed<IWriter>("barScreen");
            //compScreen = AutofacContainer.ResolveNamed<IWriter>("compScreen");
            //caller = AutofacContainer.ResolveNamed<ICaller>("caller");
            //mifareCardReader = AutofacContainer.ResolveNamed<IReader>("mifareCardReader");

            //签字板
            signaturePlate = AutofacContainer.ResolveNamed <ISignaturePlate>("signaturePlate");
            //金属键盘
            keyBoard = AutofacContainer.ResolveNamed <IKeyBoard>("keyBoard");
            //金属键盘数据返回
            keyBoard.RunCompletedEvent += new RunCompletedEventHandler(ReadKeyBoardCompletedEvent);
            //指纹
            finger = AutofacContainer.ResolveNamed <IFinger>("finger");
            finger.RunCompletedEvent += new RunCompletedEventHandler(ReadFingerCompletedEvent);
            //二维码
            qRCode = AutofacContainer.ResolveNamed <IQRCode>("qRCode");
            qRCode.RunCompletedEvent += new RunCompletedEventHandler(ReadQRCodeCompletedEvent);
            //邮品柜
            ypBox = AutofacContainer.ResolveNamed <IYPBox>("ypBox");
            //RFID
            rfid = AutofacContainer.ResolveNamed <IRFID>("rfid");
            //magneticCardReaderWriter.RunCompletedEvent += new RunCompletedEventHandler(ReadCardCompletedEvent);
            //icCardReaderWriter.RunCompletedEvent += new RunCompletedEventHandler(ReadCardCompletedEvent);
            idCardReader.RunCompletedEvent   += new RunCompletedEventHandler(ReadCardCompletedEvent);
            thermalPrinter.RunCompletedEvent += new RunCompletedEventHandler(PrintCompletedEvent);
            //mifareCardReader.RunCompletedEvent += new RunCompletedEventHandler(ReadCardCompletedEvent);
        }
        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 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);
                }
            }
        }
        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;
            }
        }
Example #11
0
 public YPBox()
 {
     scriptInvoker = AutofacContainer.ResolveNamed <IScriptInvoker>("scriptInvoker");
 }