diff options
author | Emma@Rory& <root@rory.gay> | 2023-08-14 05:07:51 +0200 |
---|---|---|
committer | Emma@Rory& <root@rory.gay> | 2023-08-14 05:11:21 +0200 |
commit | aa7026a17ededf7c181ed269c6388491d96e1b1e (patch) | |
tree | 963b45cebbfefb3c5cebaf4ba7134a0e32eb0147 /MatrixRoomUtils.Bot/Bot/FileStorageProvider.cs | |
parent | Add latest code before splitting projects (diff) | |
download | MatrixUtils-aa7026a17ededf7c181ed269c6388491d96e1b1e.tar.xz |
Split LibMatrix into submodule
Diffstat (limited to 'MatrixRoomUtils.Bot/Bot/FileStorageProvider.cs')
-rw-r--r-- | MatrixRoomUtils.Bot/Bot/FileStorageProvider.cs | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/MatrixRoomUtils.Bot/Bot/FileStorageProvider.cs b/MatrixRoomUtils.Bot/Bot/FileStorageProvider.cs deleted file mode 100644 index c38591d..0000000 --- a/MatrixRoomUtils.Bot/Bot/FileStorageProvider.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Text.Json; -using MatrixRoomUtils.Core.Extensions; -using MatrixRoomUtils.Core.Interfaces.Services; -using Microsoft.Extensions.Logging; - -namespace MatrixRoomUtils.Bot.Bot; - -public class FileStorageProvider : IStorageProvider { - private readonly ILogger<FileStorageProvider> _logger; - - public string TargetPath { get; } - - /// <summary> - /// Creates a new instance of <see cref="FileStorageProvider" />. - /// </summary> - /// <param name="targetPath"></param> - public FileStorageProvider(string targetPath) { - new Logger<FileStorageProvider>(new LoggerFactory()).LogInformation("test"); - Console.WriteLine($"Initialised FileStorageProvider with path {targetPath}"); - TargetPath = targetPath; - if(!Directory.Exists(targetPath)) { - Directory.CreateDirectory(targetPath); - } - } - - public async Task SaveObjectAsync<T>(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), ObjectExtensions.ToJson(value)); - - public async Task<T?> LoadObjectAsync<T>(string key) => JsonSerializer.Deserialize<T>(await File.ReadAllTextAsync(Path.Join(TargetPath, key))); - - public async Task<bool> ObjectExistsAsync(string key) => File.Exists(Path.Join(TargetPath, key)); - - public async Task<List<string>> GetAllKeysAsync() => Directory.GetFiles(TargetPath).Select(Path.GetFileName).ToList(); - - public async Task DeleteObjectAsync(string key) => File.Delete(Path.Join(TargetPath, key)); -} \ No newline at end of file |