public Switch()
        {
#if DEBUG_IN_EXTERNAL_APP
            MessageBox.Show("Attach debugger now");
#endif
            HandleAssemblyResolveEvents();
            device       = CompositionRoot.GetDeviceLayer();
            idOutOfRange = new InvalidValueException($"The switch ID must be in the range 0 .. {MaxSwitch-1}");
        }
        public static DeviceLayer GetDeviceLayer()
        {
            Log.Info("Composing device layer from connection string: {0}", Settings.Default.ConnectionString);
            var endpoint = DeviceEndpoint.FromConnectionString(Settings.Default.ConnectionString);
            var channel  = GetChannelFromEndpoint(endpoint);
            var device   = new DeviceLayer(channel);

            return(device);
        }