7a6dccc26a
Remove IW5 parser Begin implementation of dynamic parsers
80 lines
2.6 KiB
C#
80 lines
2.6 KiB
C#
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc.Razor;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using SharedLibraryCore.Database;
|
|
|
|
namespace WebfrontCore
|
|
{
|
|
public class Startup
|
|
{
|
|
private readonly IHostingEnvironment _appHost;
|
|
public static IConfigurationRoot Configuration { get; private set; }
|
|
|
|
public Startup(IHostingEnvironment env)
|
|
{
|
|
var builder = new ConfigurationBuilder()
|
|
.AddEnvironmentVariables();
|
|
|
|
Configuration = builder.Build();
|
|
|
|
_appHost = env;
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
// Add framework services.
|
|
var mvcBuilder = services.AddMvc();
|
|
|
|
foreach (var asm in Program.Manager.GetPluginAssemblies())
|
|
mvcBuilder.AddApplicationPart(asm);
|
|
|
|
services.Configure<RazorViewEngineOptions>(o =>
|
|
{
|
|
o.ViewLocationFormats.Add("/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension);
|
|
});
|
|
|
|
services.AddEntityFrameworkSqlite()
|
|
.AddDbContext<DatabaseContext>();
|
|
|
|
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
|
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
|
|
{
|
|
options.AccessDeniedPath = "/";
|
|
options.LoginPath = "/";
|
|
});
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|
{
|
|
//loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
|
|
|
if (env.IsDevelopment())
|
|
{
|
|
loggerFactory.AddDebug();
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
}
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAuthentication();
|
|
|
|
app.UseMvc(routes =>
|
|
{
|
|
routes.MapRoute(
|
|
name: "default",
|
|
template: "{controller=Home}/{action=Index}/{id?}");
|
|
});
|
|
}
|
|
}
|
|
}
|