using Microsoft.Extensions.Logging; using Unity; using Unity.Microsoft.Logging; namespace FurnitureAssemblyContracts.DI { public class UnityDependencyContainer : IDependencyContainer { private readonly IUnityContainer container; public UnityDependencyContainer() { container = new UnityContainer(); } public void AddLogging(Action configure) { // регистрируем логгер в контейнере var factory = LoggerFactory.Create(configure); container.AddExtension(new LoggingExtension(factory)); } public void RegisterType(bool isSingle) where T : class { if (isSingle) { container.RegisterSingleton(); } else { container.RegisterType(); } } public T Resolve() { return container.Resolve(); } void IDependencyContainer.RegisterType(bool isSingle) { if (isSingle) { container.RegisterSingleton(); } else { container.RegisterType(); } } } }