mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-07 21:58:06 -05:00
Startup namespace/cleanup
This commit is contained in:
parent
f2b273b878
commit
2464c58ccf
@ -38,12 +38,12 @@ namespace IW4MAdmin.WebfrontCore
|
|||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
// allow CORS
|
// allow CORS
|
||||||
services.AddCors(_options =>
|
services.AddCors(options =>
|
||||||
{
|
{
|
||||||
_options.AddPolicy("AllowAll",
|
options.AddPolicy("AllowAll",
|
||||||
_builder =>
|
builder =>
|
||||||
{
|
{
|
||||||
_builder.AllowAnyOrigin()
|
builder.AllowAnyOrigin()
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowAnyHeader();
|
.AllowAnyHeader();
|
||||||
});
|
});
|
||||||
@ -62,21 +62,6 @@ namespace IW4MAdmin.WebfrontCore
|
|||||||
opt.QueueProcessingOrder = QueueProcessingOrder.NewestFirst;
|
opt.QueueProcessingOrder = QueueProcessingOrder.NewestFirst;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
IEnumerable<Assembly> pluginAssemblies()
|
|
||||||
{
|
|
||||||
string pluginDir = $"{Utilities.OperatingDirectory}Plugins{Path.DirectorySeparatorChar}";
|
|
||||||
|
|
||||||
if (Directory.Exists(pluginDir))
|
|
||||||
{
|
|
||||||
var dllFileNames =
|
|
||||||
Directory.GetFiles($"{Utilities.OperatingDirectory}Plugins{Path.DirectorySeparatorChar}",
|
|
||||||
"*.dll");
|
|
||||||
return dllFileNames.Select(_file => Assembly.LoadFrom(_file));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Enumerable.Empty<Assembly>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add framework services.
|
// Add framework services.
|
||||||
var mvcBuilder = services.AddMvc(options => options.SuppressAsyncSuffixInActionNames = false);
|
var mvcBuilder = services.AddMvc(options => options.SuppressAsyncSuffixInActionNames = false);
|
||||||
services.AddFluentValidationAutoValidation().AddFluentValidationClientsideAdapters();
|
services.AddFluentValidationAutoValidation().AddFluentValidationClientsideAdapters();
|
||||||
@ -84,15 +69,15 @@ namespace IW4MAdmin.WebfrontCore
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
{
|
{
|
||||||
mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation();
|
mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation();
|
||||||
services.Configure<RazorViewEngineOptions>(_options =>
|
services.Configure<RazorViewEngineOptions>(options =>
|
||||||
{
|
{
|
||||||
_options.ViewLocationFormats.Add(@"/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension);
|
options.ViewLocationFormats.Add(@"/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension);
|
||||||
_options.ViewLocationFormats.Add("/Views/Plugins/Stats/Advanced.cshtml");
|
options.ViewLocationFormats.Add("/Views/Plugins/Stats/Advanced.cshtml");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach (var asm in pluginAssemblies())
|
foreach (var asm in PluginAssemblies())
|
||||||
{
|
{
|
||||||
mvcBuilder.AddApplicationPart(asm);
|
mvcBuilder.AddApplicationPart(asm);
|
||||||
}
|
}
|
||||||
@ -112,22 +97,32 @@ namespace IW4MAdmin.WebfrontCore
|
|||||||
services.AddTransient<IValidator<FindClientRequest>, FindClientRequestValidator>();
|
services.AddTransient<IValidator<FindClientRequest>, FindClientRequestValidator>();
|
||||||
services.AddSingleton<IResourceQueryHelper<FindClientRequest, FindClientResult>, ClientService>();
|
services.AddSingleton<IResourceQueryHelper<FindClientRequest, FindClientResult>, ClientService>();
|
||||||
services.AddSingleton<IResourceQueryHelper<StatsInfoRequest, StatsInfoResult>, StatsResourceQueryHelper>();
|
services.AddSingleton<IResourceQueryHelper<StatsInfoRequest, StatsInfoResult>, StatsResourceQueryHelper>();
|
||||||
services
|
services.AddSingleton<IResourceQueryHelper<StatsInfoRequest, AdvancedStatsInfo>, AdvancedClientStatsResourceQueryHelper>();
|
||||||
.AddSingleton<IResourceQueryHelper<StatsInfoRequest, AdvancedStatsInfo>,
|
|
||||||
AdvancedClientStatsResourceQueryHelper>();
|
|
||||||
services.AddSingleton(typeof(IDataValueCache<,>), typeof(DataValueCache<,>));
|
services.AddSingleton(typeof(IDataValueCache<,>), typeof(DataValueCache<,>));
|
||||||
services.AddSingleton<IResourceQueryHelper<BanInfoRequest, BanInfo>, BanInfoResourceQueryHelper>();
|
services.AddSingleton<IResourceQueryHelper<BanInfoRequest, BanInfo>, BanInfoResourceQueryHelper>();
|
||||||
|
return;
|
||||||
|
|
||||||
|
IEnumerable<Assembly> PluginAssemblies()
|
||||||
|
{
|
||||||
|
var pluginDir = $"{Utilities.OperatingDirectory}Plugins{Path.DirectorySeparatorChar}";
|
||||||
|
|
||||||
|
if (!Directory.Exists(pluginDir)) return [];
|
||||||
|
|
||||||
|
var dllFileNames =
|
||||||
|
Directory.GetFiles($"{Utilities.OperatingDirectory}Plugins{Path.DirectorySeparatorChar}",
|
||||||
|
"*.dll");
|
||||||
|
return dllFileNames.Select(Assembly.LoadFrom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
app.UseStatusCodePages(_context =>
|
app.UseStatusCodePages(context =>
|
||||||
{
|
{
|
||||||
if (_context.HttpContext.Response.StatusCode == (int)HttpStatusCode.NotFound)
|
if (context.HttpContext.Response.StatusCode == (int)HttpStatusCode.NotFound)
|
||||||
{
|
{
|
||||||
_context.HttpContext.Response.Redirect(
|
context.HttpContext.Response.Redirect($"/Home/ResponseStatusCode?statusCode={context.HttpContext.Response.StatusCode}");
|
||||||
$"/Home/ResponseStatusCode?statusCode={_context.HttpContext.Response.StatusCode}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@ -137,7 +132,6 @@ namespace IW4MAdmin.WebfrontCore
|
|||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Home/Error");
|
app.UseExceptionHandler("/Home/Error");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user