PIBD14-Boyko-M.S.-GSM-Autot.../ProjectGSM/Program.cs

56 lines
2.2 KiB
C#
Raw Permalink Normal View History

2024-11-19 00:15:28 +04:00
using System.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
2024-11-05 03:59:13 +04:00
using ProjectGSM.Forms;
using ProjectGSM.Repositories;
using ProjectGSM.Repositories.Implementations;
2024-11-19 00:15:28 +04:00
using Serilog;
2024-11-05 03:59:13 +04:00
using Unity;
using Unity.Lifetime;
2024-11-19 00:15:28 +04:00
using Unity.Microsoft.Logging;
2024-11-05 03:59:13 +04:00
2024-11-04 14:41:45 +04:00
namespace ProjectGSM
{
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 03:59:13 +04:00
Application.Run((CreateContainer().Resolve<FormAdvocateApp>()));
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
2024-11-19 00:15:28 +04:00
container.AddExtension(new
LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IConnectionString,
PSQLConnectionString>(new SingletonLifetimeManager());
container.RegisterType<IAdvocateRepository, AdvocateRepository>(new TransientLifetimeManager());
2024-11-05 03:59:13 +04:00
container.RegisterType<ICaseRepository, CaseRepository>(new TransientLifetimeManager());
container.RegisterType<IClientRepository, ClientRepository>(new TransientLifetimeManager());
container.RegisterType<ICourtRepository, CourtRepository>(new TransientLifetimeManager());
container.RegisterType<IStatusHistoryRepository, StatusHistoryRepository>(new TransientLifetimeManager());
return container;
2024-11-04 14:41:45 +04:00
}
2024-11-19 00:15:28 +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-04 14:41:45 +04:00
}
}