-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
40 lines (38 loc) · 1.55 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
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using Test_IBS.Interfaces;
using Test_IBS.Models;
namespace Test_IBS
{
class Program
{
static async Task Main(string[] args)
{
var host = CreateDefaultBuilder(args).Build();
using var serviceScope = host.Services.CreateScope();
var services = serviceScope.ServiceProvider;
var coreService = services.GetRequiredService<ICoreService>();
await coreService.StartAsync();
}
static IHostBuilder CreateDefaultBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.SetMinimumLevel(LogLevel.None);
})
.ConfigureServices((_, services) =>
services.AddSingleton<ICoreService, CoreService>()
.AddSingleton<IUserService, UserService>()
.AddSingleton<ITodoService, TodoService>()
.AddSingleton<IPostService, PostService>()
.AddSingleton<IDataRepository<User>, UserRepository>()
.AddSingleton<IDataRepository<Todo>, TodoRepository>()
.AddSingleton<IDataRepository<Post>, PostRepository>()
.AddHttpClient()
.AddLogging());
}
}
}