about summary refs log tree commit diff
path: root/LibMatrix/Services/ServiceInstaller.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix/Services/ServiceInstaller.cs')
-rw-r--r--LibMatrix/Services/ServiceInstaller.cs29
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";
+}