[Blazor WASM] Lazing loading DLL > Web/Blazor

본문 바로가기
사이트 내 전체검색

Web/Blazor

[Blazor WASM] Lazing loading DLL

페이지 정보

작성자 sbLAB 댓글 0건 조회 377회 작성일 21-12-28 01:47

본문

​RadZen 라이브러리를 settings 메뉴에서만 로드할 경우 예제

- Radzen.Blazor 라이브러리 Nuget 설치 및 Client -> index.html 에 Radzen.Blazor 의 js/css 설정까지는 해주고..


 Okpro.Client.csproj 


  <ItemGroup>

    <BlazorWebAssemblyLazyLoad Include="Radzen.Blazor.dll" />

  </ItemGroup>



 Okpro.Client -> App.razor 


@using Okpro.Client.Shared

@inject Microsoft.AspNetCore.Components.WebAssembly.Services.LazyAssemblyLoader AssemblyLoader


<Error>

    <CascadingAuthenticationState>

        <Router AppAssembly="@typeof(Program).Assembly"

                AdditionalAssemblies="lazyLoadedAssemblies"

                OnNavigateAsync="OnNavigation">


            <Found Context="routeData">

                <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">

                    <NotAuthorized>                       

                    </NotAuthorized>

                    <Authorizing>

                    </Authorizing>

                </AuthorizeRouteView>

            </Found>

            <NotFound>

                <LayoutView Layout="@typeof(MainLayout)">

                    <p>Access Denied</p>

                </LayoutView>

            </NotFound>

        </Router>

    </CascadingAuthenticationState>

</Error>


@code {


    private List<System.Reflection.Assembly> lazyLoadedAssemblies = new List<System.Reflection.Assembly>();

   

    private async Task OnNavigation(NavigationContext context)

    {

        if (context.Path == "" || context.Path == "settings") // Url of the page that needs the lazy loaded assembly

        {

            var assemblies = await AssemblyLoader.LoadAssembliesAsync(new[] { "MudBlazor.dll" });

           lazyLoadedAssemblies.AddRange(assemblies);

        }


    }   


}

댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
50
어제
59
최대
124
전체
45,516

그누보드5
Copyright © sebom.com All rights reserved.