From cb8846a7a3310f8513989da5aadb5202f048a1b3 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 14 Aug 2023 19:46:11 +0200 Subject: Code cleanup --- LibMatrix.ExampleBot/Bot/FileStorageProvider.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'LibMatrix.ExampleBot/Bot/FileStorageProvider.cs') diff --git a/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs b/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs index 249aba3..1e84ab7 100644 --- a/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs +++ b/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs @@ -23,13 +23,16 @@ public class FileStorageProvider : IStorageProvider { } } - public async Task SaveObjectAsync(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), ObjectExtensions.ToJson(value)); + public async Task SaveObjectAsync(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), value?.ToJson()); public async Task LoadObjectAsync(string key) => JsonSerializer.Deserialize(await File.ReadAllTextAsync(Path.Join(TargetPath, key))); - public async Task ObjectExistsAsync(string key) => File.Exists(Path.Join(TargetPath, key)); + public Task ObjectExistsAsync(string key) => Task.FromResult(File.Exists(Path.Join(TargetPath, key))); - public async Task> GetAllKeysAsync() => Directory.GetFiles(TargetPath).Select(Path.GetFileName).ToList(); + public Task> GetAllKeysAsync() => Task.FromResult(Directory.GetFiles(TargetPath).Select(Path.GetFileName).ToList()); - public async Task DeleteObjectAsync(string key) => File.Delete(Path.Join(TargetPath, key)); + public Task DeleteObjectAsync(string key) { + File.Delete(Path.Join(TargetPath, key)); + return Task.CompletedTask; + } } -- cgit 1.5.1