using System.Net.Http.Json; using GameIdeas.BlazorApp; using GameIdeas.BlazorApp.Pages.Games.Gateways; using GameIdeas.BlazorApp.Services; using GameIdeas.Resources; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); UriBuilder uriBuilder = new(builder.HostEnvironment.BaseAddress) { Port = 8000 }; builder.Services.AddHttpClient( "GameIdeas.WebAPI", client => { client.BaseAddress = uriBuilder.Uri; client.Timeout = TimeSpan.FromMinutes(3); }); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); var app = builder.Build(); await FetchTranslation(app); await app.RunAsync(); static async Task FetchTranslation(WebAssemblyHost app) { var client = app.Services.GetService()?.CreateClient("GameIdeas.WebAPI") ?? throw new Exception("Http client not found"); var response = await client.GetAsync("api/Translations"); var dictionary = await response.Content.ReadFromJsonAsync>(); if (dictionary != null) { app.Services.GetService()!.Initialize(dictionary); ResourcesKey.Initialize(app.Services.GetService()!); } }