-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathProgram.cs
More file actions
30 lines (24 loc) · 832 Bytes
/
Program.cs
File metadata and controls
30 lines (24 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using MinimalWebAPI;
using var composition = new Composition();
var builder = WebApplication.CreateBuilder(args);
// Uses Composition as an alternative IServiceProviderFactory
builder.Host.UseServiceProviderFactory(composition);
var app = builder.Build();
// Creates an application composition root of type `Owned<Program>`
using var root = composition.Root;
root.Value.Run(app);
partial class Program(
IClockViewModel clock,
IAppViewModel appModel)
{
private void Run(WebApplication app)
{
app.MapGet("/", (
// Dependencies can be injected here as well
[FromServices] ILogger<Program> logger) => {
logger.LogInformation("Start of request execution");
return new ClockResult(appModel.Title, clock.Date, clock.Time);
});
app.Run();
}
}