52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using LDBproject.Repositories.Implementations;
|
|
using LDBproject.Repositories;
|
|
using Unity;
|
|
using Unity.Microsoft.Logging;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using Serilog;
|
|
|
|
|
|
namespace LDBproject
|
|
{
|
|
internal static class Program
|
|
{
|
|
[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<MainForm>());
|
|
}
|
|
|
|
private static IUnityContainer CreateContainer()
|
|
{
|
|
var container = new UnityContainer();
|
|
|
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
|
|
|
container.RegisterType<IBookRep, BookR>();
|
|
container.RegisterType<ICustomerCardsRep, CustomerCardR>();
|
|
container.RegisterType<ILibrarianRep, LibrarianR>();
|
|
container.RegisterType<IOrderRep, OrderR>();
|
|
container.RegisterType<IUpdateRep, UpdateR>();
|
|
|
|
container.RegisterType<IConnectionString, ConnectionStrR>();
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |