-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
WindowsApiChecker.cs
69 lines (60 loc) · 2.98 KB
/
WindowsApiChecker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using UnityEngine;
#if WINDOWS_UWP
using Windows.Foundation.Metadata;
#endif
namespace Microsoft.MixedReality.Toolkit.Windows.Utilities
{
/// <summary>
/// Helper class for determining if a Windows API contract is available.
/// <remarks> See https://docs.microsoft.com/en-us/uwp/extension-sdks/windows-universal-sdk
/// for a full list of contracts.</remarks>
/// </summary>
public static class WindowsApiChecker
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void CheckApiContracts()
{
#if WINDOWS_UWP
UniversalApiContractV8_IsAvailable = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8);
UniversalApiContractV7_IsAvailable = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7);
UniversalApiContractV6_IsAvailable = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6);
UniversalApiContractV5_IsAvailable = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5);
UniversalApiContractV4_IsAvailable = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4);
UniversalApiContractV3_IsAvailable = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3);
#else
UniversalApiContractV8_IsAvailable = false;
UniversalApiContractV7_IsAvailable = false;
UniversalApiContractV6_IsAvailable = false;
UniversalApiContractV5_IsAvailable = false;
UniversalApiContractV4_IsAvailable = false;
UniversalApiContractV3_IsAvailable = false;
#endif
}
/// <summary>
/// Is the Universal API Contract v8.0 Available?
/// </summary>
public static bool UniversalApiContractV8_IsAvailable { get; private set; }
/// <summary>
/// Is the Universal API Contract v7.0 Available?
/// </summary>
public static bool UniversalApiContractV7_IsAvailable { get; private set; }
/// <summary>
/// Is the Universal API Contract v6.0 Available?
/// </summary>
public static bool UniversalApiContractV6_IsAvailable { get; private set; }
/// <summary>
/// Is the Universal API Contract v5.0 Available?
/// </summary>
public static bool UniversalApiContractV5_IsAvailable { get; private set; }
/// <summary>
/// Is the Universal API Contract v4.0 Available?
/// </summary>
public static bool UniversalApiContractV4_IsAvailable { get; private set; }
/// <summary>
/// Is the Universal API Contract v3.0 Available?
/// </summary>
public static bool UniversalApiContractV3_IsAvailable { get; private set; }
}
}