diff --git a/RenovationWork/ImplementationExtensions/RenovationWorkContracts.dll b/RenovationWork/ImplementationExtensions/RenovationWorkContracts.dll index 537d74d..2d7e809 100644 Binary files a/RenovationWork/ImplementationExtensions/RenovationWorkContracts.dll and b/RenovationWork/ImplementationExtensions/RenovationWorkContracts.dll differ diff --git a/RenovationWork/ImplementationExtensions/RenovationWorkDatabaseImplement.dll b/RenovationWork/ImplementationExtensions/RenovationWorkDatabaseImplement.dll index 73ce218..d33c870 100644 Binary files a/RenovationWork/ImplementationExtensions/RenovationWorkDatabaseImplement.dll and b/RenovationWork/ImplementationExtensions/RenovationWorkDatabaseImplement.dll differ diff --git a/RenovationWork/ImplementationExtensions/RenovationWorkFileImplement.dll b/RenovationWork/ImplementationExtensions/RenovationWorkFileImplement.dll index 068dd2b..3073333 100644 Binary files a/RenovationWork/ImplementationExtensions/RenovationWorkFileImplement.dll and b/RenovationWork/ImplementationExtensions/RenovationWorkFileImplement.dll differ diff --git a/RenovationWork/RenovationWorkContracts/DI/UnityDependencyContainer.cs b/RenovationWork/RenovationWorkContracts/DI/UnityDependencyContainer.cs new file mode 100644 index 0000000..7eaa3ae --- /dev/null +++ b/RenovationWork/RenovationWorkContracts/DI/UnityDependencyContainer.cs @@ -0,0 +1,43 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Unity; +using Unity.Microsoft.Logging; + +namespace RenovationWorkContracts.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/RenovationWork/RenovationWorkContracts/RenovationWorkContracts.csproj b/RenovationWork/RenovationWorkContracts/RenovationWorkContracts.csproj index 6b1e6c8..74123fd 100644 --- a/RenovationWork/RenovationWorkContracts/RenovationWorkContracts.csproj +++ b/RenovationWork/RenovationWorkContracts/RenovationWorkContracts.csproj @@ -8,6 +8,8 @@ + +