ITextFileStore.cs 598 B

123456789101112131415161718192021
  1. namespace RackPeek.Domain.Persistence.Yaml;
  2. public interface ITextFileStore
  3. {
  4. Task<bool> ExistsAsync(string path);
  5. Task<string> ReadAllTextAsync(string path);
  6. Task WriteAllTextAsync(string path, string contents);
  7. }
  8. public sealed class PhysicalTextFileStore : ITextFileStore
  9. {
  10. public Task<bool> ExistsAsync(string path)
  11. => Task.FromResult(File.Exists(path));
  12. public Task<string> ReadAllTextAsync(string path)
  13. => File.ReadAllTextAsync(path);
  14. public Task WriteAllTextAsync(string path, string contents)
  15. => File.WriteAllTextAsync(path, contents);
  16. }