-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
47 lines (43 loc) · 1.64 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
42
43
44
45
46
47
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
using ProjetZORK.Services.Extensions;
using System.Threading.Tasks;
using ProjetZORK.DataAccessLayer.Extensions;
using Microsoft.Extensions.Logging;
using ProjetZORK.theGame;
namespace ProjetZORK
{
class Program
{
static Task Main(string[] args)
{
using IHost host = CreateHostBuilder(args).Build().SeedDatabase();
var run = host.RunAsync();
var launcher = host.Services.GetService<Launcher>();
launcher.Exit += (o, e) => host.StopAsync();
launcher.Start();
return run;
}
static IHostBuilder CreateHostBuilder(string[] args)
{
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.AddCommandLine(args)
.Build();
return Host.CreateDefaultBuilder(args).ConfigureServices((_, services) =>
{
services.AddSingleton<Launcher>().AddSingleton<Game>().AddDataService();
services.AddLogging(
builder =>
{
builder.AddFilter("Microsoft", LogLevel.Warning)
.AddFilter("System", LogLevel.Warning)
.AddFilter("NToastNotify", LogLevel.Warning)
.AddConsole();
});
});
}
}
}