2022-03-19 23:06:06 +04:00
|
|
|
|
using System;
|
2021-03-28 19:48:15 +04:00
|
|
|
|
using Unity;
|
|
|
|
|
using Unity.Lifetime;
|
|
|
|
|
|
2022-03-20 10:10:44 +04:00
|
|
|
|
namespace ToolsModule.ManagmentDependency
|
2021-03-28 19:48:15 +04:00
|
|
|
|
{
|
2022-03-19 23:06:06 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Работа с UnityContainer
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UnityContainerManager : IDependencyManager
|
2021-03-28 19:48:15 +04:00
|
|
|
|
{
|
|
|
|
|
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);
|
2021-03-28 19:48:15 +04:00
|
|
|
|
}
|
|
|
|
|
}
|