diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 19:46:11 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 19:46:11 +0200 |
commit | cb8846a7a3310f8513989da5aadb5202f048a1b3 (patch) | |
tree | cfbcf2506947d0f820208dd4cdb7a56c660ef0f9 /LibMatrix/Services/ServiceInstaller.cs | |
parent | Update dependencies (diff) | |
download | LibMatrix-cb8846a7a3310f8513989da5aadb5202f048a1b3.tar.xz |
Code cleanup
Diffstat (limited to '')
-rw-r--r-- | LibMatrix/Services/ServiceInstaller.cs | 16 |
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; } |