src/ChessTrainerApp/BlazorExtensions/ExpandedRouteView.cs
/// <summary>
/// Renders the page at the specified route.
/// </summary>
/// <remarks>
/// Based on https://github.com/aspnet/AspNetCore/blob/master/src/Components/Components/src/RouteView.cs and
/// https://github.com/aspnet/AspNetCore/blob/master/src/Components/Components/src/LayoutView.cs.
/// </remarks>
Renders the page at the specified route.
Renders the page at the specified route .
protected override void Render(RenderTreeBuilder builder)
        {
            var pageLayoutType = RouteData.PageType.GetCustomAttribute<LayoutAttribute>()?.LayoutType ?? DefaultLayout;
            var parameterAttributeType = typeof(ParameterAttribute);
            var parametersExpected = pageLayoutType.GetProperties()
                .Where(p => p.CustomAttributes.Any(a => parameterAttributeType.IsAssignableFrom(a.AttributeType)))
                .Select(p => p.Name)
                .ToList();
            var index = 0;
            builder.OpenComponent(index++, pageLayoutType);
            builder.AddAttribute(index++, "Body", new RenderFragment(RenderPageWithParameters));
            parametersExpected.Remove("Body");
            AddParametersFromPage(builder, RouteData.PageType, parametersExpected, ref index);
            foreach (var name in parametersExpected)
            {
                builder.AddAttribute(index++, name, (object)null!);
            }
            builder.CloseComponent();
        }
protected override void Render ( RenderTreeBuilder builder ) { var pageLayoutType = RouteData . PageType . GetCustomAttribute < LayoutAttribute > ( ) ? . LayoutType ?? DefaultLayout ; var parameterAttributeType = typeof ( ParameterAttribute ) ; var parametersExpected = pageLayoutType . GetProperties ( ) . Where ( p => p . CustomAttributes . Any ( a => parameterAttributeType . IsAssignableFrom ( a . AttributeType ) ) ) . Select ( p => p . Name ) . ToList ( ) ; var index = 0 ; builder . OpenComponent ( index ++ , pageLayoutType ) ; builder . AddAttribute ( index ++ , " " , new RenderFragment ( RenderPageWithParameters ) ) ; parametersExpected . Remove ( " " ) ; AddParametersFromPage ( builder , RouteData . PageType , parametersExpected , ref index ) ; foreach ( var name in parametersExpected ) { builder . AddAttribute ( index ++ , name , ( object ) null ! ) ; } builder . CloseComponent ( ) ; }
Renders the page at the specified route.
Renders the page at the specified route .
// Get the layout page type (either from the page or from the default) // Pass null for any additional expected parameters that weren't defined by the page
builder
RenderTreeBuilder
remarks
None