-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
56 lines (48 loc) · 1.67 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
48
49
50
51
52
53
54
55
56
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NetJoy.Core.Config;
using NetJoy.Core.NetJoy;
using NetJoy.Core.NetJoy.Client;
using NetJoy.Core.NetJoy.Server;
using NetJoy.Core.Utils;
namespace NetJoy
{
static class Program
{
//create the configuration field
private static readonly Configuration Config = ConfigService.ReadConfig();
private static void Main()
{
//set the title of the console
Console.Title = "NetJoy - QuillDev";
//start in an async context
StartAsync().GetAwaiter().GetResult();
}
/// <summary>
/// Start the program in an asynchronous context
/// </summary>
/// <returns></returns>
private static async Task StartAsync()
{
//create the service provider
var services = ConfigureServices();
//get the NetJoy manager
var netJoyManager = services.GetRequiredService<NetJoyManager>();
//TODO use this again later
await netJoyManager.Start(); //start the NetJoy manager
await Task.Delay(Timeout.Infinite).ConfigureAwait(false);
}
private static IServiceProvider ConfigureServices()
{
return new ServiceCollection()
.AddSingleton(Config)
.AddSingleton<NetJoyManager>()
.AddSingleton<NetJoyClient>()
.AddSingleton<NetJoyServer>()
.AddSingleton<NgrokUtils>()
.BuildServiceProvider();
}
}
}