public static Bootstrapper UseMicrosoftDependencyInjection(this Bootstrapper bootstrapper, IServiceCollection services, params string[] excludedDllsForAutoRegistration) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var service = new MicrosoftDependencyInjectionService { BootstrappAction = (ctx) => { AddComponentRegistrationToContainer(services, bootstrapper.IoCRegistrations); AddAutoRegisteredTypes(bootstrapper, services, excludedDllsForAutoRegistration); DIManager.Init(new MicrosoftScopeFactory(services)); } }; bootstrapper.AddService(service); return(bootstrapper); }
public static Bootstrapper UseMicrosoftDependencyInjection(this Bootstrapper bootstrapper, IServiceCollection services, params string[] excludedDllsForAutoRegistration) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var service = new MicrosoftDependencyInjectionService (_ => { AddComponentRegistrationToContainer(services, bootstrapper.IoCRegistrations.ToList()); AddAutoRegisteredTypes(bootstrapper, services, excludedDllsForAutoRegistration); services.AddScoped <IScopeFactory>(s => new MicrosoftScopeFactory(s)); services.AddScoped <IScope>(s => s.GetRequiredService <IScopeFactory>().CreateScope()); DIManager.Init(new MicrosoftScopeFactory(services)); } ); bootstrapper.AddService(service); return(bootstrapper); }