-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
36 lines (29 loc) · 1.21 KB
/
Program.cs
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
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.JSInterop;
using SerbleWebsite;
using SerbleWebsite.Data;
Console.WriteLine("Loading Serble Page...");
WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient {BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)});
builder.Services.AddLocalisations();
builder.Services.AddScoped<ImageService>();
WebAssemblyHost host = builder.Build();
// Init globalisation
IJSRuntime js = host.Services.GetRequiredService < IJSRuntime > ();
string lang = await js.InvokeAsync < string > ("getCultureLang");
await host.Services.SetLanguage(lang);
Console.WriteLine("Language: " + lang);
Localiser localiser = new();
HtmlInteractor html = new(js);
await html.SetHtml("blazor-unhandled-error", localiser["unknown-error-occured"]);
await html.SetHtml("blazor-reload-link", localiser["reload"]);
try {
await host.RunAsync();
}
catch (Exception e) {
Console.Error.WriteLine("Sorry, an error has occured: " + e.Message);
Console.Error.WriteLine(e);
}