public void ConfigureApplication(IApplicationBuilder app)
            {
                var activeModuleStarters = _starters.Where(IsActiveModule).ToArray();

                // Configure all modular pipelines
                var pipelineBuilder = new RequestPipelineBuilder {
                    ApplicationBuilder = app, ApplicationContext = _appContext
                };

                foreach (var starter in activeModuleStarters)
                {
                    starter.BuildPipeline(pipelineBuilder);
                }
                pipelineBuilder.Build(app);

                // Map all modular endpoints
                app.UseEndpoints(endpoints =>
                {
                    var routeBuilder = new EndpointRoutingBuilder {
                        ApplicationBuilder = app, ApplicationContext = _appContext, RouteBuilder = endpoints
                    };
                    foreach (var starter in activeModuleStarters)
                    {
                        starter.MapRoutes(routeBuilder);
                    }
                    routeBuilder.Build(endpoints);
                });
            }
Exemple #2
0
            public void ConfigureApplication(IApplicationBuilder app)
            {
                var providerContainer = (_appContext as IServiceProviderContainer)
                                        ?? throw new ApplicationException($"The implementation of '${nameof(IApplicationContext)}' must also implement '${nameof(IServiceProviderContainer)}'.");

                providerContainer.ApplicationServices = app.ApplicationServices;

                // At this stage - after the service container was built - we can set the scoped service container.
                _engine.Scope = new ScopedServiceContainer(
                    app.ApplicationServices.GetRequiredService <ILifetimeScopeAccessor>(),
                    app.ApplicationServices.GetRequiredService <IHttpContextAccessor>(),
                    app.ApplicationServices.AsLifetimeScope());

                var activeModuleStarters = _starters.Where(IsActiveModule).ToArray();

                // Configure all modular pipelines
                var pipelineBuilder = new RequestPipelineBuilder {
                    ApplicationBuilder = app, ApplicationContext = _appContext
                };

                foreach (var starter in activeModuleStarters)
                {
                    starter.BuildPipeline(pipelineBuilder);
                }
                pipelineBuilder.Build(app);

                // Map all modular endpoints
                app.UseEndpoints(endpoints =>
                {
                    var routeBuilder = new EndpointRoutingBuilder {
                        ApplicationBuilder = app, ApplicationContext = _appContext, RouteBuilder = endpoints
                    };
                    foreach (var starter in activeModuleStarters)
                    {
                        starter.MapRoutes(routeBuilder);
                    }
                    routeBuilder.Build(endpoints);
                });
            }