C# - UWP: What's available?

By , 5/24/2015
(0 ratings)
You can share the most of your code in the new UWP. But not every class will work properly on every plattform, like the Gpio classes which will only work with the required Hardware.
Microsoft give us new static methods to check if something is available before calling it.

Neccessary Namespace

Hint: The given namespace contains also some other classes which can be helpful for self written class libraries.
var gpioIsAvailable1 = ApiInformation.IsTypePresent(nameof(Windows) 
                                                  + nameof(Windows.Devices) 
                                                  + nameof(Windows.Devices.Gpio)
                                                  + nameof(GpioController));
//maybe better without nameof...
var gpioIsAvailable2 = ApiInformation.IsTypePresent("Windows.Devices.Gpio.GpioController");

//There exists much more static methods in the ApiInformation class!
Tagged with UWP, API, Verf├╝gbarkeit, Apps.



Log in, to comment!