public ScanningContext(IServiceCollection services) { if (services == null) { throw new ArgumentNullException(nameof(services)); } LocalServices.TryAddSingleton(services); }
public void Initialize() { // Guard against double initialization if (Initialized) { throw new ScanningContextInitializedException(); } Initialized = true; // Initialize the modules using var serviceProvider = LocalServices.BuildServiceProvider(); var modules = _modulesTypeInfo .KeepOnlyDependencyInjectionModules() .Distinct() ; foreach (var module in modules) { using var _ = ActivatorUtilities.CreateInstance(serviceProvider, module.AsType()) as IDisposable; } }
public LocalModel GetLocalById(String _idLocal) { var _local = new LocalServices().GetLocalById(_idLocal); return(_local); }