forked from julianperrott/WowClassicGrindBot
-
-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathDependencyInjection.cs
More file actions
66 lines (54 loc) · 2.42 KB
/
DependencyInjection.cs
File metadata and controls
66 lines (54 loc) · 2.42 KB
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
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using SharedLib;
namespace HeadlessServer;
public static class DependencyInjection
{
public static void AddStartupConfigFactories(this IServiceCollection services)
{
services.AddSingleton<IOptions<StartupConfigPathing>>(StartupConfigPathingFactory);
services.AddSingleton<IOptions<StartupConfigReader>>(StartupConfigReaderFactory);
services.AddSingleton<IOptions<StartupConfigPid>>(StartupConfigPidFactory);
services.AddSingleton<IOptions<StartupConfigDiagnostics>>(StartupConfigDiagnosticsFactory);
services.AddSingleton<IOptions<StartupConfigNpcOverlay>>(StartupConfigNpcOverlayFactory);
}
private static IOptions<StartupConfigPathing> StartupConfigPathingFactory(IServiceProvider sp)
{
var options = sp.GetRequiredService<RunOptions>();
return Options.Create<StartupConfigPathing>(
new(options.Mode.ToString()!,
options.Hostv1!, options.Portv1,
options.Hostv3!, options.Portv3,
options.PathVisualizer));
}
private static IOptions<StartupConfigReader> StartupConfigReaderFactory(IServiceProvider sp)
{
var options = sp.GetRequiredService<RunOptions>();
return Options.Create<StartupConfigReader>(
new() { Type = options.Reader.ToString(), UseGpu = options.UseGpu });
}
private static IOptions<StartupConfigPid> StartupConfigPidFactory(IServiceProvider sp)
{
var options = sp.GetRequiredService<RunOptions>();
return Options.Create<StartupConfigPid>(
new() { Id = options.Pid });
}
private static IOptions<StartupConfigDiagnostics> StartupConfigDiagnosticsFactory(IServiceProvider sp)
{
var options = sp.GetRequiredService<RunOptions>();
return Options.Create<StartupConfigDiagnostics>(
new() { Enabled = options.Diagnostics });
}
private static IOptions<StartupConfigNpcOverlay> StartupConfigNpcOverlayFactory(IServiceProvider sp)
{
var options = sp.GetRequiredService<RunOptions>();
return Options.Create<StartupConfigNpcOverlay>(
new()
{
Enabled = options.OverlayEnabled,
ShowTargeting = options.OverlayTargeting,
ShowSkinning = options.OverlaySkinning,
ShowTargetVsAdd = options.OverlayTargetVsAdd,
});
}
}