using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.Json; using System.Threading.Tasks; namespace LocalDataStorageWithSQLite.StorageUtils { internal class FileSystemStorage { private string _dir = $"{FileSystem.AppDataDirectory}/Temp"; public FileSystemStorage() { if (!Directory.Exists(_dir)) Directory.CreateDirectory(_dir); } public T Get(string key) { string path = Path.Combine(_dir, key); if (!File.Exists(path)) return default(T); string raw = File.ReadAllText(path); T result = JsonSerializer.Deserialize(raw); return result; } public void Set(string key, T value) { var serialized = JsonSerializer.Serialize(value); string path = Path.Combine(_dir, key); File.WriteAllText(path, serialized); } } }