DepartmentProject/DepartmentPortal/Common/ModuleTools/BusinessLogics/UnityContainerManager.cs

22 lines
652 B
C#
Raw Normal View History

using ModuleTools.Interfaces;
using Unity;
using Unity.Lifetime;
namespace ModuleTools.BusinessLogics
{
/// <summary>
/// Работа с UnityContainer
/// </summary>
public class UnityContainerManager : IDependencyManager
{
private readonly IUnityContainer _unityContainer;
public UnityContainerManager() => _unityContainer = new UnityContainer();
public void RegisterType<T, U>() where U : T => _unityContainer.RegisterType<T, U>(new HierarchicalLifetimeManager());
public void RegisterType<T>() => _unityContainer.RegisterType<T>(new HierarchicalLifetimeManager());
public T Resolve<T>() => _unityContainer.Resolve<T>();
}
}