using System.Text.Json; using System.Text.Json.Serialization; using Blazored.LocalStorage; using Blazored.SessionStorage; using LibMatrix.Services; using MatrixRoomUtils.Web; using MatrixRoomUtils.Web.Classes; 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"); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddBlazoredLocalStorage(config => { config.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase; config.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; config.JsonSerializerOptions.IgnoreReadOnlyProperties = true; config.JsonSerializerOptions.PropertyNameCaseInsensitive = true; config.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; config.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip; config.JsonSerializerOptions.WriteIndented = false; }); builder.Services.AddBlazoredSessionStorage(config => { config.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase; config.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; config.JsonSerializerOptions.IgnoreReadOnlyProperties = true; config.JsonSerializerOptions.PropertyNameCaseInsensitive = true; config.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; config.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip; config.JsonSerializerOptions.WriteIndented = false; }); builder.Services.AddScoped(x => new( cacheStorageProvider: new SessionStorageProviderService(x.GetRequiredService()), dataStorageProvider: new LocalStorageProviderService(x.GetRequiredService()) ) ); builder.Services.AddRoryLibMatrixServices(); builder.Services.AddScoped(); await builder.Build().RunAsync();