public Task Store(string key, ResourceDocument resourceDocument) { EnsureDirectoryExists(); var filePath = Path.Combine(_storageDirectory.FullName, $"{key.Replace('/', '-')}.json"); var json = ResourceDocumentSerializer.SerializeToJson(resourceDocument); return(File.WriteAllTextAsync(filePath, json, Encoding.UTF8)); }
private async Task <ResourceDocument?> LoadFromFile(string filePath) { try { var json = await File.ReadAllTextAsync(filePath, Encoding.UTF8); return(ResourceDocumentSerializer.DeserializeFromJson(json)); } catch (Exception ex) { _logger.LogError(ex, $"Failed to load resource from '{filePath}'."); return(null); } }