Gets the specified SDK. The SDK name. The SDK instance or null if not supported.
(string name)
| 78 | /// <param name="name">The SDK name.</param> |
| 79 | /// <returns>The SDK instance or null if not supported.</returns> |
| 80 | public static Sdk Get(string name) |
| 81 | { |
| 82 | if (_sdks == null) |
| 83 | { |
| 84 | using (new ProfileEventScope("GetSdks")) |
| 85 | { |
| 86 | _sdks = new Dictionary<string, Sdk>(); |
| 87 | var types = Builder.BuildTypes.Where(x => !x.IsAbstract && x.IsSubclassOf(typeof(Sdk))); |
| 88 | foreach (var type in types) |
| 89 | { |
| 90 | object instance = null; |
| 91 | var instanceField = type.GetField("Instance", BindingFlags.Public | BindingFlags.Static); |
| 92 | if (instanceField != null) |
| 93 | { |
| 94 | instance = instanceField.GetValue(null); |
| 95 | } |
| 96 | else if (type.GetConstructor(Type.EmptyTypes) != null) |
| 97 | { |
| 98 | instance = Activator.CreateInstance(type); |
| 99 | } |
| 100 | if (instance != null) |
| 101 | _sdks.Add(type.Name, (Sdk)instance); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | _sdks.TryGetValue(name, out var result); |
| 107 | return result; |
| 108 | } |
| 109 | |
| 110 | /// <summary> |
| 111 | /// Returns true if SDK is supported and is valid. |
no test coverage detected