2024-11-13 23:20:06 +04:00
|
|
|
using GasStation.Repositories;
|
|
|
|
using GasStation.Repositories.Implementations;
|
2024-12-09 14:34:46 +04:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Serilog;
|
|
|
|
using Unity.Microsoft.Logging;
|
2024-11-13 23:20:06 +04:00
|
|
|
using System.Drawing.Text;
|
|
|
|
using Unity;
|
|
|
|
|
|
|
|
namespace GasStation;
|
|
|
|
|
|
|
|
internal static class Program
|
2024-10-30 14:51:04 +04:00
|
|
|
{
|
2024-11-13 23:20:06 +04:00
|
|
|
/// <summary>
|
|
|
|
/// The main entry point for the application.
|
|
|
|
/// </summary>
|
|
|
|
[STAThread]
|
|
|
|
static void Main()
|
2024-10-30 14:51:04 +04:00
|
|
|
{
|
2024-11-13 23:20:06 +04:00
|
|
|
// To customize application configuration such as set high DPI settings or default font,
|
|
|
|
// see https://aka.ms/applicationconfiguration.
|
|
|
|
ApplicationConfiguration.Initialize();
|
|
|
|
Application.Run(CreateContainer().Resolve<FormGasStation>());
|
|
|
|
}
|
|
|
|
|
|
|
|
private static IUnityContainer CreateContainer()
|
|
|
|
{
|
|
|
|
var container = new UnityContainer();
|
|
|
|
|
2024-12-09 14:34:46 +04:00
|
|
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
|
|
|
|
2024-11-13 23:20:06 +04:00
|
|
|
container.RegisterType<IGasmanRepository, GasmanRepository>();
|
|
|
|
container.RegisterType<ISellingRepository,SellingRepository>();
|
|
|
|
container.RegisterType<ISupplierRepository, SupplierRepository>();
|
|
|
|
container.RegisterType<ISupplyRepository, SupplyRepository>();
|
2024-11-15 18:27:06 +04:00
|
|
|
container.RegisterType<IProductRepository, ProductRepository>();
|
2024-12-09 14:34:46 +04:00
|
|
|
container.RegisterType<IConnectionString, ConnectionString>();
|
2024-11-13 23:20:06 +04:00
|
|
|
|
|
|
|
return container;
|
2024-10-30 14:51:04 +04:00
|
|
|
}
|
2024-12-09 14:34:46 +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-10-30 14:51:04 +04:00
|
|
|
}
|