diff --git a/FlowerShop/FlowerShop/FlowerShopView.csproj b/FlowerShop/FlowerShop/FlowerShopView.csproj index cd8fa87..034ab28 100644 --- a/FlowerShop/FlowerShop/FlowerShopView.csproj +++ b/FlowerShop/FlowerShop/FlowerShopView.csproj @@ -24,6 +24,7 @@ + diff --git a/FlowerShop/FlowerShopContracts/DI/UnityDependencyContainer.cs b/FlowerShop/FlowerShopContracts/DI/UnityDependencyContainer.cs new file mode 100644 index 0000000..7e6941b --- /dev/null +++ b/FlowerShop/FlowerShopContracts/DI/UnityDependencyContainer.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Logging; +using Unity.Microsoft.Logging; +using Unity; + +namespace FlowerShopContracts.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); + } + } +} diff --git a/FlowerShop/FlowerShopContracts/FlowerShopContracts.csproj b/FlowerShop/FlowerShopContracts/FlowerShopContracts.csproj index a164789..f7857b4 100644 --- a/FlowerShop/FlowerShopContracts/FlowerShopContracts.csproj +++ b/FlowerShop/FlowerShopContracts/FlowerShopContracts.csproj @@ -8,6 +8,8 @@ + +