clean up
parent
6baf12a6b4
commit
587495dc10
|
@ -1,4 +1,4 @@
|
||||||
#define RDG13F // RDG13 RDG13F
|
#define RDG13 // RDG13 RDG13F
|
||||||
#if NEVER
|
#if NEVER
|
||||||
#elif RDG13
|
#elif RDG13
|
||||||
// <snippet_1>
|
// <snippet_1>
|
||||||
|
@ -7,8 +7,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.AddKeyedSingleton<IService, FizzService>("fizz");
|
builder.Services.AddKeyedSingleton<IService, FizzService>("fizz");
|
||||||
builder.Services.AddKeyedSingleton<IService, BuzzService>("buzz");
|
|
||||||
builder.Services.AddSingleton<IService, FizzBuzzService>();
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.MapGet("/fizz", ([FromKeyedServices("fizz")][FromServices] IService service) =>
|
app.MapGet("/fizz", ([FromKeyedServices("fizz")][FromServices] IService service) =>
|
||||||
|
@ -16,18 +14,8 @@ app.MapGet("/fizz", ([FromKeyedServices("fizz")][FromServices] IService service)
|
||||||
return Results.Ok(service.Echo());
|
return Results.Ok(service.Echo());
|
||||||
});
|
});
|
||||||
|
|
||||||
app.MapGet("/buzz", ([FromKeyedServices("buzz")] IService service) =>
|
|
||||||
{
|
|
||||||
return Results.Ok(service.Echo());
|
|
||||||
});
|
|
||||||
|
|
||||||
app.MapGet("/fizzbuzz", ([FromServices] IService service) =>
|
|
||||||
{
|
|
||||||
return Results.Ok(service.Echo());
|
|
||||||
});
|
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
// </snippet_1>
|
||||||
public interface IService
|
public interface IService
|
||||||
{
|
{
|
||||||
string Echo();
|
string Echo();
|
||||||
|
@ -40,23 +28,6 @@ public class FizzService : IService
|
||||||
return "Fizz";
|
return "Fizz";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BuzzService : IService
|
|
||||||
{
|
|
||||||
public string Echo()
|
|
||||||
{
|
|
||||||
return "Buzz";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FizzBuzzService : IService
|
|
||||||
{
|
|
||||||
public string Echo()
|
|
||||||
{
|
|
||||||
return "FizzBuzz";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// </snippet_1>
|
|
||||||
#elif RDG13F
|
#elif RDG13F
|
||||||
// <snippet_1f>
|
// <snippet_1f>
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
Loading…
Reference in New Issue