2024-11-05 23:39:22 +04:00
|
|
|
using ProjectGarage.Repositories;
|
|
|
|
using ProjectGarage.Repositories.Implementations;
|
2024-11-30 16:03:41 +04:00
|
|
|
using Unity.Lifetime;
|
2024-11-05 23:39:22 +04:00
|
|
|
using Unity;
|
2024-11-30 16:03:41 +04:00
|
|
|
using Unity.Microsoft.Logging;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Serilog;
|
2024-11-05 23:39:22 +04:00
|
|
|
|
2024-11-02 19:41:16 +04:00
|
|
|
namespace ProjectGarage
|
|
|
|
{
|
|
|
|
internal static class Program
|
|
|
|
{
|
|
|
|
/// <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();
|
2024-11-05 23:39:22 +04:00
|
|
|
Application.Run(CreateContainer().Resolve<FormGarage>());
|
|
|
|
}
|
|
|
|
|
|
|
|
private static IUnityContainer CreateContainer()
|
|
|
|
{
|
|
|
|
var container = new UnityContainer();
|
2024-11-30 16:03:41 +04:00
|
|
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
2024-11-05 23:39:22 +04:00
|
|
|
|
|
|
|
container.RegisterType<ITruckRepository, TruckRepository>();
|
|
|
|
container.RegisterType<IFuelRepository, FuelRepository>();
|
|
|
|
container.RegisterType<IRouteRepository, RouteRepository>();
|
|
|
|
container.RegisterType<IDriverRepository, DriverRepository>();
|
|
|
|
container.RegisterType<ITransportationRepository, TransportationRepository>();
|
2024-12-17 19:58:30 +04:00
|
|
|
container.RegisterType<IReplenishmentRepository, ReplenishmentRepository>();
|
2024-11-05 23:39:22 +04:00
|
|
|
|
2024-11-28 22:46:58 +04:00
|
|
|
container.RegisterType<IConnectionString, ConnectionString>();
|
|
|
|
|
2024-11-05 23:39:22 +04:00
|
|
|
return container;
|
2024-11-02 19:41:16 +04:00
|
|
|
}
|
2024-11-30 16:03:41 +04:00
|
|
|
|
|
|
|
private static LoggerFactory CreateLoggerFactory()
|
|
|
|
{
|
|
|
|
var loggerFactory = new LoggerFactory();
|
|
|
|
loggerFactory.AddSerilog(new LoggerConfiguration()
|
|
|
|
.ReadFrom.Configuration(new ConfigurationBuilder()
|
|
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
|
|
.AddJsonFile("appsettings.json")
|
|
|
|
.Build())
|
|
|
|
.CreateLogger());
|
|
|
|
return loggerFactory;
|
|
|
|
}
|
2024-11-02 19:41:16 +04:00
|
|
|
}
|
|
|
|
}
|