获取当前设备系列

这里有一个简单的便携方式来获取当前的设备系列:

/// <summary>
/// All the device families 
/// </summary>
public enum DeviceFamily
{
    Desktop,
    Mobile,
    Iot,
    Xbox,
}

/// <summary>
/// The helper to get the current device family
/// </summary>
public static class DeviceFamilyHelper
{
    /// <summary>
    /// Return the family of the current device
    /// </summary>
    /// <returns>the family of the current device</returns>
    public static DeviceFamily GetDeviceFamily()
    {
        switch(ResourceContext.GetForCurrentView().QualifierValues["DeviceFamily"].ToLowerInvariant())
        {
            case "mobile":  return DeviceFamily.Mobile;    
            case "xbox":    return DeviceFamily.Xbox;
            case "iot":     return DeviceFamily.Iot;
            default:        return DeviceFamily.Desktop;
        }
    }
}