PIbd-33_Sergunov_M.A._COP_4/Library/LibraryView/Program.cs

47 lines
1.4 KiB
C#

using LibraryBusinessLogic.BusinessLogics;
using LibraryContracts.BusinessLogicsContracts;
using LibraryContracts.StorageContracts;
using LibraryDatabaseImplement.Implements;
using Unity;
using Unity.Lifetime;
namespace LibraryView
{
public static class Program
{
private static IUnityContainer container = null;
public static IUnityContainer Container
{
get
{
if (container == null)
{
container = BuildUnityContainer();
}
return container;
}
}
/// <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.
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(Container.Resolve<FormMain>());
}
private static IUnityContainer BuildUnityContainer()
{
var currentContainer = new UnityContainer();
currentContainer.RegisterType<IBookStorage, BookStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IBookLogic, BookLogic>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IGenreStorage, GenreStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IGenreLogic, GenreLogic>(new HierarchicalLifetimeManager());
return currentContainer;
}
}
}