コード例 #1
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            if (!CanHandleRoute(RouteContext))
            {
                Logger.LogInformation($"[{Segments}]: No match. Bypassing route");
                return;
            }

            MetalRouteContext nextcontext = RouteContext.MoveCapturedToParent(this, _segmentCollection);

            Logger.LogInformation($"[{Segments}]: Match. Handling route");
            Logger.LogInformation($"[{Segments}]: New Context: {nextcontext}");
            builder.OpenRegion(0);

            if (Layout is not null)
            {
                builder.OpenComponent <LayoutView>(0);
                builder.AddAttribute(1, "Layout", Layout);
                builder.AddAttribute(2, "ChildContent", ChildContent(nextcontext));
                builder.CloseComponent();
            }
            else
            {
                builder.AddContent(0, ChildContent(nextcontext));
            }

            builder.CloseRegion();
            _selfHandledRoute = true;
        }