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

24 lines
717 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using Unity;
using Unity.Lifetime;
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>();
public object Resolve(Type t) => _unityContainer.Resolve(t);
}
}