DepartmentProject/DepartmentPortal/Common/ToolsModule/ManagmentDependency/UnityContainerManager.cs

24 lines
717 B
C#
Raw Normal View History

using System;
using Unity;
using Unity.Lifetime;
2022-03-20 10:10:44 +04:00
namespace ToolsModule.ManagmentDependency
{
/// <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>();
2021-03-30 22:34:31 +04:00
public object Resolve(Type t) => _unityContainer.Resolve(t);
}
}