diff options
Diffstat (limited to 'MatrixRoomUtils.Core/Services')
-rw-r--r-- | MatrixRoomUtils.Core/Services/HomeserverProviderService.cs | 4 | ||||
-rw-r--r-- | MatrixRoomUtils.Core/Services/ServiceInstaller.cs | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/MatrixRoomUtils.Core/Services/HomeserverProviderService.cs b/MatrixRoomUtils.Core/Services/HomeserverProviderService.cs index 3db4584..0f09a45 100644 --- a/MatrixRoomUtils.Core/Services/HomeserverProviderService.cs +++ b/MatrixRoomUtils.Core/Services/HomeserverProviderService.cs @@ -1,5 +1,3 @@ -using MatrixRoomUtils.Core.Attributes; - namespace MatrixRoomUtils.Core.Services; public class HomeserverProviderService { @@ -13,6 +11,6 @@ public class HomeserverProviderService { } public async Task<AuthenticatedHomeServer> GetAuthenticatedWithToken(string homeserver, string accessToken) { - return await new AuthenticatedHomeServer(homeserver, accessToken, _tieredStorageService).Configure(); + return await new AuthenticatedHomeServer(_tieredStorageService, homeserver, accessToken).Configure(); } } \ No newline at end of file diff --git a/MatrixRoomUtils.Core/Services/ServiceInstaller.cs b/MatrixRoomUtils.Core/Services/ServiceInstaller.cs index 43255d8..1b275c5 100644 --- a/MatrixRoomUtils.Core/Services/ServiceInstaller.cs +++ b/MatrixRoomUtils.Core/Services/ServiceInstaller.cs @@ -1,16 +1,27 @@ -using MatrixRoomUtils.Core.Interfaces.Services; using Microsoft.Extensions.DependencyInjection; namespace MatrixRoomUtils.Core.Services; public static class ServiceInstaller { - public static IServiceCollection AddRoryLibMatrixServices(this IServiceCollection services) { + 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 != null) + services.AddSingleton(config); + else { + services.AddSingleton(new RoryLibMatrixConfiguration()); + } + //Add services services.AddScoped<HomeserverProviderService>(); return services; } +} + +public class RoryLibMatrixConfiguration { + public string AppName { get; set; } = "Rory&::LibMatrix"; } \ No newline at end of file |