about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Program.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-18 07:03:47 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-18 07:04:00 +0200
commitd4f46b4fb6dfd2672a5205ec9de12050a940f56c (patch)
tree90be2b959a41148da84aaffbb1b0a1163aa3288e /MatrixRoomUtils.Web/Program.cs
parentStart refactor (diff)
downloadMatrixUtils-d4f46b4fb6dfd2672a5205ec9de12050a940f56c.tar.xz
Partial refactor
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