-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathApp.razor
More file actions
43 lines (40 loc) · 1.48 KB
/
App.razor
File metadata and controls
43 lines (40 loc) · 1.48 KB
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
43
@using System.Reflection
@using Microsoft.AspNetCore.Components.WebAssembly.Services
@inject LazyAssemblyLoader AssemblyLoader
@inject ILogger<App> Logger
<Router AppAssembly="@typeof(MudExtensions.Docs.Pages.Index).Assembly" AdditionalAssemblies="@_lazyLoadedAssemblies" OnNavigateAsync="@OnNavigateAsync">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MudExtensions.Docs.Shared.MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MudExtensions.Docs.Shared.MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
@code
{
private readonly List<Assembly> _lazyLoadedAssemblies = new();
private async Task OnNavigateAsync(Microsoft.AspNetCore.Components.Routing.NavigationContext args)
{
try
{
//Route to the component that contains the QR
if (args.Path == "mudbarcode" || args.Path == "api")
{
var assemblies = await AssemblyLoader
.LoadAssembliesAsync(new[]
{
"zxing.dll",
});
_lazyLoadedAssemblies.AddRange(assemblies);
}
}
catch (Exception ex)
{
Logger.LogError("Error: {Message}", ex.Message);
}
}
}