From 0d0511e35d9965fc0ea5190ae3347c3d77c3334c Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 14 Aug 2023 04:09:13 +0200 Subject: Split LibMatrix into separate repo --- LibMatrix/Services/ServiceInstaller.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 LibMatrix/Services/ServiceInstaller.cs (limited to 'LibMatrix/Services/ServiceInstaller.cs') 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(); + services.AddSingleton(); + // services.AddScoped(); + return services; + } + + +} + +public class RoryLibMatrixConfiguration { + public string AppName { get; set; } = "Rory&::LibMatrix"; +} -- cgit 1.4.1