55 lines
2.2 KiB
C#
55 lines
2.2 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using ProjectGSM.Repositories;
|
|
using ProjectGSM.Repositories.Implementations;
|
|
using Serilog;
|
|
using Unity;
|
|
using Unity.Lifetime;
|
|
using Unity.Microsoft.Logging;
|
|
|
|
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();
|
|
Application.Run((CreateContainer().Resolve<FormAdvocateApp>()));
|
|
}
|
|
|
|
private static IUnityContainer CreateContainer()
|
|
{
|
|
var container = new UnityContainer();
|
|
container.AddExtension(new
|
|
LoggingExtension(CreateLoggerFactory()));
|
|
|
|
container.RegisterType<IConnectionString,
|
|
PSQLConnectionString>(new SingletonLifetimeManager());
|
|
container.RegisterType<ICaseAdvocateRepository, CaseAdvocatesRepository>(new TransientLifetimeManager());
|
|
container.RegisterType<IAdvocateRepository, AdvocateRepository>(new TransientLifetimeManager());
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |