-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
41 lines (33 loc) · 1.52 KB
/
Program.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
using JokerService;
using JokerService.Services;
using JokerService.Settings;
using Serilog;
using Microsoft.Extensions.Options;
using JokerService.Processes;
var serilogSettings = new SerilogSettings();
serilogSettings.ConfigureSerilog();
IHost host = Host.CreateDefaultBuilder(args)
.UseWindowsService()
.ConfigureServices((hostContext, services) =>
{
services.AddWindowsService(options =>
{
options.ServiceName = "Jokers Manor";
});
services.Configure<FileSystemSettings>(hostContext.Configuration.GetSection("FileSystemSettings"));
services.Configure<TimersSettings>(hostContext.Configuration.GetSection("TimersSettings"));
services.Configure<EmailSettings>(hostContext.Configuration.GetSection("EmailSettings"));
// Register Settings Class(s) as a singleton
services.AddSingleton(resolver => resolver.GetRequiredService<IOptions<FileSystemSettings>>().Value);
services.AddSingleton(resolver => resolver.GetRequiredService<IOptions<TimersSettings>>().Value);
services.AddSingleton(resolver => resolver.GetRequiredService<IOptions<EmailSettings>>().Value);
services.AddSingleton<EmailService>();
services.AddSingleton<MsTeamsService>();
services.AddSingleton<JokeService>();
services.AddSingleton<TextBuilderService>();
services.AddSingleton<JokeBuilderProcess>();
services.AddHostedService<Worker>();
})
.UseSerilog()
.Build();
host.Run();