-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (43 loc) · 1.29 KB
/
Program.cs
File metadata and controls
48 lines (43 loc) · 1.29 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
using CardsTools.Commands;
using CardsTools.Data.Managers;
using CardsTools.Hosting;
using CardsTools.Persistence;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Sinks.SystemConsole.Themes;
namespace CardsTools;
internal static class Program
{
public static async Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Console(theme: AnsiConsoleTheme.Literate)
.CreateLogger();
try
{
var builder = Host.CreateApplicationBuilder(args);
builder.Logging.ClearProviders();
builder.Services.AddSerilog(Log.Logger);
builder.Services
.AddSingleton<IDeckStorage, JsonDeckStorage>()
.AddSingleton<CardManager>()
.AddSingleton<CommandRunner>()
.AddHostedService<ConsoleAppService>();
var host = builder.Build();
await host.RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "fatal error");
return 1;
}
finally
{
await Log.CloseAndFlushAsync();
}
}
}