From ed2205972a7b7d6fdd4563c3775a83616920597a Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 19 Jun 2023 02:36:32 +0200 Subject: Working sync --- .../Services/HomeserverProviderService.cs | 18 ++++++++++++++++++ MatrixRoomUtils.Core/Services/HomeserverService.cs | 8 -------- MatrixRoomUtils.Core/Services/ServiceInstaller.cs | 16 ++++++++++++++++ MatrixRoomUtils.Core/Services/TieredStorageService.cs | 6 +++++- 4 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 MatrixRoomUtils.Core/Services/HomeserverProviderService.cs delete mode 100644 MatrixRoomUtils.Core/Services/HomeserverService.cs create mode 100644 MatrixRoomUtils.Core/Services/ServiceInstaller.cs (limited to 'MatrixRoomUtils.Core/Services') diff --git a/MatrixRoomUtils.Core/Services/HomeserverProviderService.cs b/MatrixRoomUtils.Core/Services/HomeserverProviderService.cs new file mode 100644 index 0000000..3db4584 --- /dev/null +++ b/MatrixRoomUtils.Core/Services/HomeserverProviderService.cs @@ -0,0 +1,18 @@ +using MatrixRoomUtils.Core.Attributes; + +namespace MatrixRoomUtils.Core.Services; + +public class HomeserverProviderService { + private readonly TieredStorageService _tieredStorageService; + + public HomeserverProviderService(TieredStorageService tieredStorageService) { + Console.WriteLine("Homeserver provider service instantiated!"); + _tieredStorageService = tieredStorageService; + Console.WriteLine( + $"New HomeserverProviderService created with TieredStorageService<{string.Join(", ", tieredStorageService.GetType().GetProperties().Select(x => x.Name))}>!"); + } + + public async Task GetAuthenticatedWithToken(string homeserver, string accessToken) { + return await new AuthenticatedHomeServer(homeserver, accessToken, _tieredStorageService).Configure(); + } +} \ No newline at end of file diff --git a/MatrixRoomUtils.Core/Services/HomeserverService.cs b/MatrixRoomUtils.Core/Services/HomeserverService.cs deleted file mode 100644 index ba48e6c..0000000 --- a/MatrixRoomUtils.Core/Services/HomeserverService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using MatrixRoomUtils.Core.Attributes; - -namespace MatrixRoomUtils.Core.Services; - -[Trace] -public class HomeserverService { - -} \ No newline at end of file diff --git a/MatrixRoomUtils.Core/Services/ServiceInstaller.cs b/MatrixRoomUtils.Core/Services/ServiceInstaller.cs new file mode 100644 index 0000000..43255d8 --- /dev/null +++ b/MatrixRoomUtils.Core/Services/ServiceInstaller.cs @@ -0,0 +1,16 @@ +using MatrixRoomUtils.Core.Interfaces.Services; +using Microsoft.Extensions.DependencyInjection; + +namespace MatrixRoomUtils.Core.Services; + +public static class ServiceInstaller { + + public static IServiceCollection AddRoryLibMatrixServices(this IServiceCollection services) { + if (!services.Any(x => x.ServiceType == typeof(TieredStorageService))) + throw new Exception("[MRUCore/DI] No TieredStorageService has been registered!"); + services.AddScoped(); + return services; + } + + +} \ No newline at end of file diff --git a/MatrixRoomUtils.Core/Services/TieredStorageService.cs b/MatrixRoomUtils.Core/Services/TieredStorageService.cs index f6beddd..2f27443 100644 --- a/MatrixRoomUtils.Core/Services/TieredStorageService.cs +++ b/MatrixRoomUtils.Core/Services/TieredStorageService.cs @@ -3,7 +3,11 @@ using MatrixRoomUtils.Core.Interfaces.Services; namespace MatrixRoomUtils.Core.Services; public class TieredStorageService { + public IStorageProvider CacheStorageProvider { get; } + public IStorageProvider DataStorageProvider { get; } + public TieredStorageService(IStorageProvider cacheStorageProvider, IStorageProvider dataStorageProvider) { - + CacheStorageProvider = cacheStorageProvider; + DataStorageProvider = dataStorageProvider; } } \ No newline at end of file -- cgit 1.5.1