using System.Collections.ObjectModel; using System.Text.Json; using NoteApp.Model; namespace NoteApp.Service; public class FileService { private readonly string _fileName; public FileService(){ _fileName = Path.Combine(FileSystem.AppDataDirectory, "notes.json"); } public async Task> LoadNotes(){ if(!File.Exists(_fileName)) return []; var json = await File.ReadAllTextAsync(_fileName); return JsonSerializer.Deserialize>(json) ?? []; } public async Task SaveNotes(ObservableCollection notes){ var json = JsonSerializer.Serialize(notes); await File.WriteAllTextAsync(_fileName, json); } }