initial changes to migrate to new Blazor approach in .NET 8

This commit is contained in:
sbwalker
2024-01-30 16:03:50 -05:00
parent 7fcfffba6f
commit 82d7b9cf05
8 changed files with 479 additions and 605 deletions

View File

@ -0,0 +1,29 @@
#nullable enable
using Oqtane.Components;
using Microsoft.AspNetCore.Components.Endpoints;
using Microsoft.AspNetCore.Routing;
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace OqtaneSSR.Extensions
{
public static class ComponentEndpointRouteBuilderExtensions
{
public static void MapFallback(this IEndpointRouteBuilder endpoints)
{
ArgumentNullException.ThrowIfNull(endpoints);
endpoints.MapFallback((ctx) =>
{
var invoker = ctx.RequestServices.GetRequiredService<IRazorComponentEndpointInvoker>();
return invoker.Render(ctx);
})
.Add(routeEndpointBuilder =>
{
routeEndpointBuilder.Metadata.Add(new RootComponentMetadata(typeof(App)));
routeEndpointBuilder.Metadata.Add(new ComponentTypeMetadata(typeof(App)));
});
}
}
}