9 hours ago, Dr Herbie wrote
I'm resurrecting this thread as I now find I have some time to write a wrapper to hide the (IMHO) appalling API design that is ApiInformation.IsApiContractPresent. If the wrapper is good enough, I'll open source it.
So, opinions on how to design the library, taking the 'VibrationDevice' as the starting point. Which seems like the better API:
1. A static class where you just call
And if there is a vibration device it will be used, but if there isn't nothing will happen (optional return value indicating whether it happened or not).
2. The same format as the MS VibrationDevice class where you call
device = VibrationDevice.GetDefault();
But without the nasty exception throwing, using a NullObject replacement to perform the empty implementation.
I'm currently leaning to option 1 as it seems cleaner to call (being just a hardware interface) rather than having to create an instance using a static factory method.
Other opinions are sought.