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

37 lines
1.3 KiB
C#
Raw Permalink Normal View History

using ClientsContracts.BusinessLogicContracts;
using ClientsContracts.StorageContracts;
using ClientsDatabaseImplement.Implements;
using Unity;
using Unity.Lifetime;
2023-09-13 18:53:06 +04:00
namespace WinForms
{
internal static class Program
{
private static IUnityContainer container = null;
public static IUnityContainer Container { get { if (container == null) { container = BuildUnityContainer(); } return container; } }
2023-09-13 18:53:06 +04:00
/// <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;
2023-09-13 18:53:06 +04:00
}
}
}