about summary refs log tree commit diff
path: root/LibMatrix/Services/ServiceInstaller.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-08-14 19:46:11 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-08-14 19:46:11 +0200
commitcb8846a7a3310f8513989da5aadb5202f048a1b3 (patch)
treecfbcf2506947d0f820208dd4cdb7a56c660ef0f9 /LibMatrix/Services/ServiceInstaller.cs
parentUpdate dependencies (diff)
downloadLibMatrix-cb8846a7a3310f8513989da5aadb5202f048a1b3.tar.xz
Code cleanup
Diffstat (limited to 'LibMatrix/Services/ServiceInstaller.cs')
-rw-r--r--LibMatrix/Services/ServiceInstaller.cs16
1 files changed, 10 insertions, 6 deletions
diff --git a/LibMatrix/Services/ServiceInstaller.cs b/LibMatrix/Services/ServiceInstaller.cs
index 96a1963..b1c98e1 100644
--- a/LibMatrix/Services/ServiceInstaller.cs
+++ b/LibMatrix/Services/ServiceInstaller.cs
@@ -9,14 +9,18 @@ public static class ServiceInstaller {
         if (!services.Any(x => x.ServiceType == typeof(TieredStorageService)))
             throw new Exception("[MRUCore/DI] No TieredStorageService has been registered!");
         //Add config
-        if(config is not null)
-            services.AddSingleton(config);
-        else {
-            services.AddSingleton(new RoryLibMatrixConfiguration());
-        }
+        services.AddSingleton(config ?? new RoryLibMatrixConfiguration());
+
         //Add services
-        services.AddSingleton<HomeserverProviderService>();
         services.AddSingleton<HomeserverResolverService>();
+
+        if (services.First(x => x.ServiceType == typeof(TieredStorageService)).Lifetime == ServiceLifetime.Singleton) {
+            services.AddSingleton<HomeserverProviderService>();
+        }
+        else {
+            services.AddScoped<HomeserverProviderService>();
+        }
+
         // services.AddScoped<MatrixHttpClient>();
         return services;
     }