87 lines
3.3 KiB
C#
87 lines
3.3 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using NLog.Extensions.Logging;
|
|
using RouteGuideBusinessLogics.BusinessLogics;
|
|
using RouteGuideContracts.BusinessLogicsContracts;
|
|
using RouteGuideContracts.StoragesContracts;
|
|
using RouteGuideMongoDBImplement.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>();
|
|
|
|
// IoC-êîíòåéíåð, ôîðìû äëÿ òåñòîâ
|
|
services.AddTransient<FormSchedulesTests>();
|
|
services.AddTransient<FormDriversTests>();
|
|
services.AddTransient<FormTransportTests>();
|
|
services.AddTransient<FormRoutesTests>();
|
|
services.AddTransient<FormStopsTests>();
|
|
|
|
// Çàïèñü DateTime Kind=Local â ÁÄ
|
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
|
}
|
|
}
|
|
} |