//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.Web.AdminPanel;
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using MUnique.OpenMU.DataModel.Entities;
using MUnique.OpenMU.Web.AdminPanel.Components;
using MUnique.OpenMU.Web.AdminPanel.Services;
using MUnique.OpenMU.Web.Shared;
using MUnique.OpenMU.Web.Shared.Components.Modal;
using MUnique.OpenMU.Web.Shared.Models;
using MUnique.OpenMU.Web.Shared.Services;
///
/// The startup class for the blazor app.
///
///
/// This class is only used when running as all-in-one deployment.
///
public class Startup
{
///
/// Initializes a new instance of the class.
///
/// The configuration.
public Startup(IConfiguration configuration)
{
this.Configuration = configuration;
}
///
/// Gets the configuration.
///
///
/// The configuration.
///
public IConfiguration Configuration { get; }
///
/// This method gets called by the runtime. Use this method to add services to the container.
/// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940.
///
/// The service collection.
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorComponents()
.AddInteractiveServerComponents();
services.AddSignalR().AddJsonProtocol(o => o.PayloadSerializerOptions.Converters.Add(new TimeSpanConverter()));
services.AddControllers()
.ConfigureApplicationPartManager(setup =>
setup.FeatureProviders.Add(new GenericControllerFeatureProvider()));
services.AddToasts();
services.AddScoped();
services.AddScoped(sp => sp.GetRequiredService());
services.AddSingleton();
services.AddSingleton();
services.AddScoped();
services.AddScoped>(serviceProvider => serviceProvider.GetService()!);
services.AddScoped();
services.AddScoped>(serviceProvider => serviceProvider.GetService()!);
services.AddScoped();
services.AddScoped();
}
///
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
///
/// The app builder.
/// The web host environment.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "logs")),
RequestPath = "/logs",
});
app.UseAntiforgery();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorComponents()
.AddInteractiveServerRenderMode();
endpoints.MapControllers();
});
}
}