diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 04:09:13 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 04:09:13 +0200 |
commit | 0d0511e35d9965fc0ea5190ae3347c3d77c3334c (patch) | |
tree | b4e0c336cbccc37bd14952b447868a577ea15540 /LibMatrix/Services/ServiceInstaller.cs | |
download | LibMatrix-0d0511e35d9965fc0ea5190ae3347c3d77c3334c.tar.xz |
Split LibMatrix into separate repo
Diffstat (limited to '')
-rw-r--r-- | LibMatrix/Services/ServiceInstaller.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/LibMatrix/Services/ServiceInstaller.cs b/LibMatrix/Services/ServiceInstaller.cs new file mode 100644 index 0000000..96a1963 --- /dev/null +++ b/LibMatrix/Services/ServiceInstaller.cs @@ -0,0 +1,29 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace LibMatrix.Services; + +public static class ServiceInstaller { + + public static IServiceCollection AddRoryLibMatrixServices(this IServiceCollection services, RoryLibMatrixConfiguration? config = null) { + //Check required services + 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()); + } + //Add services + services.AddSingleton<HomeserverProviderService>(); + services.AddSingleton<HomeserverResolverService>(); + // services.AddScoped<MatrixHttpClient>(); + return services; + } + + +} + +public class RoryLibMatrixConfiguration { + public string AppName { get; set; } = "Rory&::LibMatrix"; +} |