PIbd-21_MasenkinMS_SUBD_Rou.../RouteGuide/RouteGuideView/Program.cs
2024-04-05 02:48:52 +04:00

77 lines
2.9 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using RouteGuideBusinessLogics.BusinessLogics;
using RouteGuideContracts.BusinessLogicsContracts;
using RouteGuideContracts.StoragesContracts;
using RouteGuideDatabaseImplement.Implements;
namespace RouteGuideView
{
internal static class Program
{
/// <summary>
/// IoC-êîíòåéíåð
/// </summary>
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
/// <summary>
/// Êîíôèãóðàöèÿ ñåðâèñîâ
/// </summary>
/// <param name="services"></param>
private static void ConfigureServices(ServiceCollection services)
{
// Ëîããåð
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
// IoC-êîíòåéíåð, õðàíèëèùà
services.AddTransient<IDriverStorage, DriverStorage>();
services.AddTransient<ITransportStorage, TransportStorage>();
services.AddTransient<IRouteStorage, RouteStorage>();
services.AddTransient<IStopStorage, StopStorage>();
services.AddTransient<IScheduleStorage, ScheduleStorage>();
// IoC-êîíòåéíåð, áèçíåñ-ëîãèêà
services.AddTransient<IDriverLogic, DriverLogic>();
services.AddTransient<ITransportLogic, TransportLogic>();
services.AddTransient<IRouteLogic, RouteLogic>();
services.AddTransient<IStopLogic, StopLogic>();
services.AddTransient<IScheduleLogic, ScheduleLogic>();
// IoC-êîíòåéíåð, ôîðìû
services.AddTransient<FormMain>();
services.AddTransient<FormSchedule>();
services.AddTransient<FormDriver>();
services.AddTransient<FormDrivers>();
services.AddTransient<FormTransport>();
services.AddTransient<FormTransports>();
services.AddTransient<FormRoute>();
services.AddTransient<FormRoutes>();
services.AddTransient<FormRouteStop>();
services.AddTransient<FormStop>();
services.AddTransient<FormStops>();
}
}
}