Beispiel #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory factory)
        {
            app.UseMiddleware <Middleware.ErrorHandlingMiddleware>();
            if (!env.IsDevelopment())
            {
                app.UseHsts();
            }
            app.UseSwagger();
            app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WikiLibs API"));
            app.UseHttpsRedirection();
            app.UseCors("AllowAll");
            app.UseAuthentication();
            app.UseMvc();

            using (var scope = app.ApplicationServices.CreateScope())
            {
                var collection = scope.ServiceProvider.GetService <IModuleCollection>();
                foreach (var module in collection)
                {
                    var info = (ModuleInfoInternal)module;
                    if (info.Initializer == null || info.ModuleInterface == null)
                    {
                        continue;
                    }
                    var mdInstance = scope.ServiceProvider.GetService(info.ModuleInterface);
                    ModuleHelper.AttemptCallModuleInitializer(env, info, mdInstance);
                }
            }
        }