PIbd-32_Turner_I.A._COP_10/COP/WinForms/Program.cs

37 lines
1.3 KiB
C#

using ClientsContracts.BusinessLogicContracts;
using ClientsContracts.StorageContracts;
using ClientsDatabaseImplement.Implements;
using Unity;
using Unity.Lifetime;
namespace WinForms
{
internal 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()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(Container.Resolve<FormMain>());
}
private static IUnityContainer BuildUnityContainer()
{
var currentContainer = new UnityContainer();
currentContainer.RegisterType<IClientStorage, ClientStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IStatusStorage, StatusStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IClientLogic, ClientBusinessLogic.BusinessLogics.ClientLogic>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IStatusLogic, ClientBusinessLogic.BusinessLogics.StatusLogic>(new HierarchicalLifetimeManager());
return currentContainer;
}
}
}