about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Web/Program.cs')
-rw-r--r--MatrixRoomUtils.Web/Program.cs20
1 files changed, 18 insertions, 2 deletions
diff --git a/MatrixRoomUtils.Web/Program.cs b/MatrixRoomUtils.Web/Program.cs
index 8ea8742..11e7f19 100644
--- a/MatrixRoomUtils.Web/Program.cs
+++ b/MatrixRoomUtils.Web/Program.cs
@@ -1,6 +1,8 @@
 using System.Text.Json;
 using System.Text.Json.Serialization;
 using Blazored.LocalStorage;
+using Blazored.SessionStorage;
+using MatrixRoomUtils.Core.Services;
 using MatrixRoomUtils.Web;
 using MatrixRoomUtils.Web.Classes;
 using Microsoft.AspNetCore.Components.Web;
@@ -20,9 +22,23 @@ builder.Services.AddBlazoredLocalStorage(config => {
     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.AddSingleton<LocalStorageProviderService>();
+builder.Services.AddScoped<LocalStorageProviderService>();
 builder.Services.AddSingleton<SessionStorageProviderService>();
-builder.Services.AddSingleton<TieredStorage<LocalStorageProviderService, SessionStorageProviderService>>();
+builder.Services.AddSingleton<TieredStorageService>(x =>
+    new(
+        x.GetRequiredService<SessionStorageProviderService>(),
+        x.GetRequiredService<LocalStorageProviderService>()
+    )
+);
 
 await builder.Build().RunAsync();
\ No newline at end of file