Files
ScadaBridge/src/ZB.MOM.WW.ScadaBridge.CentralUI/EndpointExtensions.cs
T

35 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using ZB.MOM.WW.ScadaBridge.CentralUI.Audit;
using ZB.MOM.WW.ScadaBridge.CentralUI.Auth;
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout;
using ZB.MOM.WW.ScadaBridge.CentralUI.ScriptAnalysis;
namespace ZB.MOM.WW.ScadaBridge.CentralUI;
public static class EndpointExtensions
{
/// <summary>
/// Maps the Central UI endpoints. The caller must provide the root App component type
/// from the Host assembly so that blazor.web.js is served correctly.
/// </summary>
/// <typeparam name="TApp">The root Blazor App component type, supplied by the Host assembly.</typeparam>
/// <param name="endpoints">The endpoint route builder to register routes on.</param>
/// <returns>The same <paramref name="endpoints"/> instance, for call chaining.</returns>
public static IEndpointRouteBuilder MapCentralUI<TApp>(this IEndpointRouteBuilder endpoints)
where TApp : Microsoft.AspNetCore.Components.IComponent
{
endpoints.MapAuthEndpoints();
endpoints.MapScriptAnalysisEndpoints();
endpoints.MapAuditExportEndpoints();
endpoints.MapRazorComponents<TApp>()
.AddInteractiveServerRenderMode()
.AddAdditionalAssemblies(
typeof(MainLayout).Assembly,
typeof(ZB.MOM.WW.Secrets.Ui.SecretsPage).Assembly);
return endpoints;
}
}