Esempio n. 1
0
        public override void Configure(IApplicationBuilder app)
        {
            _bootstrapper.SetServiceProviderInternal(app.ApplicationServices);
            _bootstrapper.Initialize(app);
            var hostingEnvironment = app.ApplicationServices.GetRequiredService <IHostingEnvironment>();
            var instance           = app.ApplicationServices.GetRequiredService(_startuModuleType);
            var action             = FindConfigureDelegate(_startuModuleType, hostingEnvironment.EnvironmentName)?.Build(instance);

            action?.Invoke(app);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="containerBuilder"></param>
        /// <returns></returns>
        public IServiceProvider CreateServiceProvider(IServiceCollection containerBuilder)
        {
            var serviceProvider = _bootstrapper.CreateServiceProvider(containerBuilder);

            _bootstrapper.SetServiceProviderInternal(serviceProvider);
            var applicationLifetime = serviceProvider.GetRequiredService <IHostApplicationLifetime>();

            applicationLifetime.ApplicationStopping.Register(() => _bootstrapper.Shutdown());
            applicationLifetime.ApplicationStopped.Register(() => (_bootstrapper as IDisposable).Dispose());
            _bootstrapper.Initialize();
            return(serviceProvider);
        }