57 lines
2.0 KiB
C#
57 lines
2.0 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using ProjectEmployeeAgency.Repositories;
|
|
using ProjectRouteAgency.Repositories;
|
|
using ProjectTourAgency.Implementations;
|
|
using ProjectTourAgency.Repositories;
|
|
using Serilog;
|
|
using Unity;
|
|
using Unity.Microsoft.Logging;
|
|
|
|
namespace ProjectTourAgency
|
|
{
|
|
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();
|
|
Application.Run(CreateContainer().Resolve<FormTourAgency>());
|
|
}
|
|
|
|
private static IUnityContainer CreateContainer()
|
|
{
|
|
var container = new UnityContainer();
|
|
|
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
|
|
|
container.RegisterType<ITourRepository, TourRepository>();
|
|
container.RegisterType<IAddMoneyRepository, AddMoneyRepository>();
|
|
container.RegisterType<IClientRepository, ClientRepository>();
|
|
container.RegisterType<IRouteRepository, RouteRepository>();
|
|
container.RegisterType<IEmployeeRepository, EmployeeRepository>();
|
|
container.RegisterType<ITourRepository, TourRepository>();
|
|
|
|
container.RegisterType<IConnectionString, ConnectionString>();
|
|
|
|
return container;
|
|
}
|
|
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;
|
|
}
|
|
|
|
}
|
|
} |