Пример #1
0
        public Emulator(IDevice device, ICryptoHandler cryptoHandler)
        {
            this.device        = device ?? throw new ArgumentNullException(nameof(device));
            this.cryptoHandler = cryptoHandler ?? throw new ArgumentNullException(nameof(cryptoHandler));

            this.device         = device;
            this.device.Output += this.OnDeviceOutput;

            this.dataLink     = new DataLink();
            this.deserializer = new Deserializer();

            this.dataLink.CommandReceived        += this.OnCommandReceived;
            this.dataLink.CorruptCommandReceived += this.OnCorruptCommandReceived;
            this.dataLink.AbortRequested         += this.OnAbortRequested;
        }
Пример #2
0
        public Interceptor(IDevice virtualDevice, IDevice realDevice)
        {
            if (virtualDevice == null)
            {
                throw new ArgumentNullException(nameof(virtualDevice));
            }
            if (realDevice == null)
            {
                throw new ArgumentNullException(nameof(realDevice));
            }

            this.virtualLink = new DataLink();
            this.virtualLink.CommandReceived += this.OnVirtualLinkCommandReceived;

            this.realLink = new DataLink();
            this.realLink.CommandReceived += this.OnRealLinkCommandReceived;

            this.virtualDevice         = virtualDevice;
            this.virtualDevice.Output += this.OnVirtualDeviceOutput;

            this.realDevice         = realDevice;
            this.realDevice.Output += this.OnRealDeviceOutput;
        }