24 lines
717 B
C#
24 lines
717 B
C#
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);
|
||
}
|
||
} |