2022-03-18 22:38:52 +04:00
|
|
|
|
using ToolsModule.Interfaces;
|
2021-03-30 22:34:31 +04:00
|
|
|
|
using System;
|
2021-03-28 19:48:15 +04:00
|
|
|
|
using Unity;
|
|
|
|
|
using Unity.Lifetime;
|
|
|
|
|
|
2022-03-18 22:38:52 +04:00
|
|
|
|
namespace ToolsModule.BusinessLogics
|
2021-03-28 19:48:15 +04:00
|
|
|
|
{
|
|
|
|
|
/// <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);
|
2021-03-28 19:48:15 +04:00
|
|
|
|
}
|
|
|
|
|
}
|