コード例 #1
0
        public virtual IPhone PluginDevice(IInterconnection device, Action <int> action = null)
        {
            if (SupportedPlugins.Contains(device.PluginToUse))
            {
                connectedDevices.Add(device);

                if (action != null)
                {
                    device.Action = action;
                }
                else if (deviceActions.ContainsKey(device.GetType().Name))
                {
                    device.Action = deviceActions[device.GetType().Name];
                }
                else
                {
                    throw new NotImplementedException($"No action provided to execute for device: {device.GetType().Name}");
                }
            }
            else
            {
                throw new NotImplementedException($"Not supported type of device connection: {device.PluginToUse}");
            }
            return(this);
        }
コード例 #2
0
        public IPhone DisconnectDevice(IInterconnection device)
        {
            if (connectedDevices.Remove(device))
            {
                device.Action = null;
            }
            ;

            return(this);
        }
コード例 #3
0
        public Form1()
        {
            InitializeComponent();

            gamePhone = new GamePhone(FormFactor.Bar, "BP20200321");
            output    = new TextBoxOutput(this.outputTextBox);

            invokeGui del1 = () => { output.WriteLine("HeadsetSony in Action"); };

            headsetAction = (i) => { outputTextBox.Invoke(del1); };

            invokeGui del2 = () => { output.WriteLine($"Phone is charging by {nameof(PowerBank)}"); };

            powerAction = (i) => { outputTextBox.Invoke(del2); };

            headsetSony = new HeadsetSony("BP20200321");

            powerBank             = new PowerBank("BP20200325");
            powerBank.PluginToUse = Plugins.Usb;
        }