private void OnDeviceRemoved(UsbDevice usbDevice) { UsbDeviceRemoved?.Invoke(this, usbDevice); if (UsbDeviceList.Any(device => device.DeviceName == usbDevice.DeviceName || device.DevicePath == usbDevice.DevicePath)) { UsbDeviceList.Remove(UsbDeviceList.First(device => device.DeviceName == usbDevice.DeviceName || device.DevicePath == usbDevice.DevicePath)); } }
private void OnDeviceRemoved(UsbDevice usbDevice) { UsbDeviceRemoved?.Invoke(this, usbDevice); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { UsbDeviceList.RemoveAll(device => device.DeviceName == usbDevice.DeviceName && device.DeviceSystemPath == usbDevice.DeviceSystemPath); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { UsbDeviceList.RemoveAll(device => device.ProductID == usbDevice.ProductID && device.VendorID == usbDevice.VendorID && device.SerialNumber == usbDevice.SerialNumber); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { UsbDeviceList.RemoveAll(device => device.SerialNumber == usbDevice.SerialNumber); } }