Jinjinov / Usb.Events

Subscribe to the Inserted and Removed events to be notified when a USB drive is plugged in or unplugged, or when a USB device is connected or disconnected. Usb.Events is a .NET Standard 2.0 library and uses WMI on Windows, libudev on Linux and IOKit on macOS.
MIT License
95 stars 23 forks source link

Use Polymorphism to simplify UsbEventWatcher type #40

Open sonicbhoc opened 5 months ago

sonicbhoc commented 5 months ago

The UsbEventWatcher type has a lot of checks for OS and a few checks for DEBUG flags. This code can be eliminated by using polymorphism to create specific types that implement IUsbEventWatcher, then instantiating the proper concrete type depending on the OS.