[Blazor WASM] Lazing loading DLL > C#/.Net/Blazor/IIS

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

C#/.Net/Blazor/IIS

[Blazor WASM] Lazing loading DLL

페이지 정보

작성자 sbLAB 댓글 0건 조회 5,882회 작성일 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);

        }


    }   


}

[이 게시물은 sbLAB님에 의해 2022-12-22 09:41:18 Web/PHP/API에서 이동 됨]

댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
319
어제
396
최대
1,279
전체
222,369

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