using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.Json; using System.Threading.Tasks; using TodoDetails.Model; namespace TodoDetails.Services { public class TodoService { Lazy>> todoList; public TodoService() { todoList = new Lazy>>( async () => { List? result = null; using var stream = await FileSystem.OpenAppPackageFileAsync("tododata.json"); using var reader = new StreamReader(stream); var contents = await reader.ReadToEndAsync(); if (contents != null) { result = JsonSerializer.Deserialize>(contents); } return result ?? new(); }); } public async Task> GetTodos() { return await todoList.Value; } } }