using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Unity.Microsoft.Logging; using Unity; namespace PlumbingRepairContracts.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 { _container.RegisterType(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient); } public T Resolve() { return _container.Resolve(); } void IDependencyContainer.RegisterType(bool isSingle) { _container.RegisterType(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient); } } }