-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.razor
42 lines (38 loc) · 1.39 KB
/
App.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@using Microsoft.AspNetCore.Components.WebAssembly.Services
@using System.Reflection
@inject LazyAssemblyLoader assemblyLoader
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true" AdditionalAssemblies="@lazyLoadedAssemblies"
OnNavigateAsync="@OnNavigateAsync">
<Navigating>
<div style="padding:20px;background-color:blue;color:white">
<p>Loading the requested page…</p>
</div>
</Navigating>
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
@code{
private List<Assembly> lazyLoadedAssemblies = new List<Assembly>();
private async Task OnNavigateAsync(NavigationContext args)
{
try
{
if (args.Path == "lazyloading")
{
Console.WriteLine("Lazy Loading assemblies ...");
var assemblies = await assemblyLoader.LoadAssembliesAsync(new string[] { "EPPlus.dll", "Newtonsoft.Json.dll" });
lazyLoadedAssemblies.AddRange(assemblies);
}
}
catch (System.Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
}
}