-
Notifications
You must be signed in to change notification settings - Fork 4
/
WheelSteerLock.cs
33 lines (28 loc) · 1.13 KB
/
WheelSteerLock.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace AcTools.WheelAngles {
public static class WheelSteerLock {
private static IWheelSteerLockSetter[] _instances;
private static void Initialize() {
if (_instances == null) {
_instances = Assembly.GetExecutingAssembly().GetTypes()
.Where(x => !x.IsAbstract && x.GetInterfaces().Contains(typeof(IWheelSteerLockSetter)))
.Select(x => (IWheelSteerLockSetter)Activator.CreateInstance(x)).ToArray();
}
}
public static IWheelSteerLockSetter Get(string productGuid) {
Initialize();
return _instances.FirstOrDefault(x => x.Test(productGuid));
}
public static bool IsSupported(string productGuid) {
Initialize();
return _instances.Any(x => x.Test(productGuid));
}
public static IEnumerable<string> GetSupportedNames() {
Initialize();
return _instances.Select(x => x.ControllerName);
}
}
}