-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (33 loc) · 1.05 KB
/
Program.cs
File metadata and controls
39 lines (33 loc) · 1.05 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
namespace FileScanner;
internal static class Program
{
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
ApplicationConfiguration.Initialize();
using var sp = Build();
using var scope = sp.CreateScope();
Application.Run(scope.ServiceProvider.GetRequiredService<MainForm>());
}
static ServiceProvider Build()
{
var s = new ServiceCollection();
s.AddSingleton(Config.Default);
s.AddSingleton<SettingsStore>();
s.AddSingleton<Files>();
s.AddSingleton<Analyzer>();
s.AddSingleton<FormLog>();
s.AddScoped<Scanner>();
s.AddTransient<MainForm>();
s.AddLogging(b =>
{
b.SetMinimumLevel(LogLevel.Debug);
b.AddFilter("Microsoft", LogLevel.Warning);
b.AddFilter("System", LogLevel.Warning);
b.Services.AddSingleton<ILoggerProvider>(
p => p.GetRequiredService<FormLog>());
});
return s.BuildServiceProvider();
}
}