Demo entry 6788997

cs

   

Submitted by anonymous on Apr 24, 2019 at 14:19
Language: C#. Code size: 1.1 kB.

    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            var controllers = ExternalManager.ExternalControllers;

            // Добавляем наш список контролеров к приложению
            services.AddMvc().ConfigureApplicationPartManager(app =>
              {
                  var p = new ExternalPartsProvider(controllers);
                  app.ApplicationParts.Add(p);
              });

            // Добавляем ссылки на файлы View для контролера
            services.Configure<RazorViewEngineOptions>(options =>
            {
                var eFiles = controllers.Select(c => new EmbeddedFileProvider(c.Assembly, c.Namespace));
                options.FileProviders.Add(new CompositeFileProvider(eFiles));
            });
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
        }
    }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).