about summary refs log tree commit diff
path: root/MatrixRoomUtils.Desktop/FileStorageProvider.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-12-02 22:36:15 +0100
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-12-02 22:36:15 +0100
commit779ced6da10e35df9273b95928ed182cddecee27 (patch)
tree90765a9e7bf6e2255503a0a4e0a4fb5d5c9fdec6 /MatrixRoomUtils.Desktop/FileStorageProvider.cs
parentUpdate upstreams (diff)
downloadMatrixUtils-779ced6da10e35df9273b95928ed182cddecee27.tar.xz
Reformat
Diffstat (limited to 'MatrixRoomUtils.Desktop/FileStorageProvider.cs')
-rw-r--r--MatrixRoomUtils.Desktop/FileStorageProvider.cs4
1 files changed, 3 insertions, 1 deletions
diff --git a/MatrixRoomUtils.Desktop/FileStorageProvider.cs b/MatrixRoomUtils.Desktop/FileStorageProvider.cs

index 7f73cf3..0429d1a 100644 --- a/MatrixRoomUtils.Desktop/FileStorageProvider.cs +++ b/MatrixRoomUtils.Desktop/FileStorageProvider.cs
@@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.Text.Json; using ArcaneLibs.Extensions; using LibMatrix.Extensions; @@ -19,13 +20,14 @@ public class FileStorageProvider : IStorageProvider { new Logger<FileStorageProvider>(new LoggerFactory()).LogInformation("test"); Console.WriteLine($"Initialised FileStorageProvider with path {targetPath}"); TargetPath = targetPath; - if(!Directory.Exists(targetPath)) { + if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } } public async Task SaveObjectAsync<T>(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), value?.ToJson()); + [RequiresUnreferencedCode("This API uses reflection to deserialize JSON")] public async Task<T?> LoadObjectAsync<T>(string key) => JsonSerializer.Deserialize<T>(await File.ReadAllTextAsync(Path.Join(TargetPath, key))); public Task<bool> ObjectExistsAsync(string key) => Task.FromResult(File.Exists(Path.Join(TargetPath, key)));