diff --git a/fundamentals/aot/diagnostics/Rdg9/Program.cs b/fundamentals/aot/diagnostics/Rdg9/Program.cs index da29dc2..2059175 100644 --- a/fundamentals/aot/diagnostics/Rdg9/Program.cs +++ b/fundamentals/aot/diagnostics/Rdg9/Program.cs @@ -18,7 +18,6 @@ builder.Services.ConfigureHttpJsonOptions(options => var app = builder.Build(); - app.MapGet("/v1/todos/{id}", ([AsParameters] TodoItemRequest request) => { return request.todos.ToList().Find(todoItem => todoItem.Id == request.Id) @@ -33,31 +32,28 @@ struct TodoItemRequest { public int Id { get; set; } - [AsParameters] public Todo[] todos { get; set; } } - internal record Todo(int Id, string Task, DateTime DueDate); - [JsonSerializable(typeof(Todo[]))] internal partial class AppJsonSerializerContext : JsonSerializerContext { } // - - #elif RDG009F // using System.Text.Json.Serialization; var builder = WebApplication.CreateSlimBuilder(); + var todos = new[] { new Todo(1, "Write tests", DateTime.UtcNow.AddDays(2)), new Todo(2, "Fix tests",DateTime.UtcNow.AddDays(1)) }; + builder.Services.AddSingleton(todos); builder.Services.ConfigureHttpJsonOptions(options => { @@ -66,7 +62,6 @@ builder.Services.ConfigureHttpJsonOptions(options => var app = builder.Build(); - app.MapGet("/v1/todos/{id}", ([AsParameters] TodoItemRequest request) => { return request.todos.ToList().Find(todoItem => todoItem.Id == request.Id) @@ -83,10 +78,8 @@ struct TodoItemRequest public Todo[] todos { get; set; } } - internal record Todo(int Id, string Task, DateTime DueDate); - [JsonSerializable(typeof(Todo[]))] internal partial class AppJsonSerializerContext : JsonSerializerContext {