using Microsoft.Extensions.Logging; using Unity.Microsoft.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Unity; namespace ConfectioneryContracts.DI { public class UnityDependancyContainer : IDependancyContainer { private readonly UnityContainer _unityContainer; public UnityDependancyContainer() { _unityContainer = new UnityContainer(); } public void AddLogging(Action configure) { _unityContainer.AddExtension(new LoggingExtension(LoggerFactory.Create(configure))); } void IDependancyContainer.RegisterType(bool isSingle) { if (isSingle) _unityContainer.RegisterSingleton(); else _unityContainer.RegisterType(); } public void RegisterType(bool isSingle) where T : class { if (isSingle) _unityContainer.RegisterSingleton(); else _unityContainer.RegisterType(); } public T Resolve() { return _unityContainer.Resolve(); } } }