using Microsoft.Extensions.Logging; namespace SushiBarContracts.DI { public class DependencyManager { private readonly IDependencyContainer _dependencyManager; private static DependencyManager? _manager; private static readonly object _locjObject = new(); private DependencyManager() { _dependencyManager = new ServiceDependencyContainer(); } public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } } public static void InitDependency() { var ext = ServiceProviderLoader.GetImplementationExtensions(); if (ext == null) { throw new ArgumentNullException("Отсутствуют компонент для загрузки зависимостей по модулям"); } ext.RegisterServices(); } public void AddLogging(Action configure) => _dependencyManager.AddLogging(configure); public void RegisterType(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType(isSingle); public void RegisterType(bool isSingle = false) where T : class => _dependencyManager.RegisterType(isSingle); public T Resolve() => _dependencyManager.Resolve(); } }