-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (26 loc) · 1.03 KB
/
Program.cs
File metadata and controls
32 lines (26 loc) · 1.03 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
using Example.PrerenderingWithWorkers;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using SpawnDev.BlazorJS;
using SpawnDev.BlazorJS.WebWorkers;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
InternalConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress, false);
// BlazorJS.WebWorkers
await builder.Build().BlazorJSRunAsync();
static void InternalConfigureServices(IServiceCollection services, string baseAddress, bool prerendering)
{
services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) });
if (!prerendering)
{
// BlazorJS.WebWorkers
services.AddBlazorJSRuntime();
services.AddWebWorkerService();
services.AddSingleton<IMyWorker, MyWorker>();
}
}
static void ConfigureServices(IServiceCollection services, string baseAddress)
{
InternalConfigureServices(services, baseAddress, true);
}