-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
34 lines (28 loc) · 1.27 KB
/
Copy pathProgram.cs
File metadata and controls
34 lines (28 loc) · 1.27 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
using LR1.Interfaces;
using LR1.Services;
using LR1.UI;
using Microsoft.Extensions.DependencyInjection;
using Spectre.Console;
// Композиционный корень приложения: здесь связываются интерфейсы и реализации.
var services = new ServiceCollection();
services.AddSingleton<IDataStore, InMemoryDataStore>();
services.AddSingleton<ILoggerService, LoggerService>();
services.AddSingleton<IUndoService, UndoService>();
services.AddSingleton<IAuthService, AuthService>();
services.AddSingleton<IClientService, ClientService>();
services.AddSingleton<IManagerService, ManagerService>();
services.AddSingleton<IAdminService, AdminService>();
services.AddSingleton<IAppInitializer, AppInitializer>();
services.AddSingleton<IExceptionHandler, ExceptionHandler>();
services.AddSingleton<IConsoleUi, ConsoleUi>();
var provider = services.BuildServiceProvider();
try
{
// Первичная загрузка демонстрационных данных выполняется один раз.
provider.GetRequiredService<IAppInitializer>().Seed();
provider.GetRequiredService<IConsoleUi>().Run();
}
catch (Exception ex)
{
AnsiConsole.MarkupLine($"[red]Критическая ошибка:[/] {Markup.Escape(ex.Message)}");
}