mirror of
https://github.com/PacktPublishing/Learn-WinUI-3-Second-Edition.git
synced 2026-06-20 12:23:09 +00:00
Adding code for completed chapter 13 solution
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using Uno.Wasm.Bootstrap.Server;
|
||||
using UnoMediaCollection.DataContracts.Serialization;
|
||||
|
||||
try
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Configure the JsonOptions to use the generated WeatherForecastContext
|
||||
builder.Services.Configure<JsonOptions>(options =>
|
||||
options.JsonSerializerOptions.AddContext<WeatherForecastContext>());
|
||||
// Configure the RouteOptions to use lowercase URLs
|
||||
builder.Services.Configure<RouteOptions>(options =>
|
||||
options.LowercaseUrls = true);
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
// Include XML comments for all included assemblies
|
||||
Directory.EnumerateFiles(AppContext.BaseDirectory, "*.xml")
|
||||
.Where(x => x.Contains("UnoMediaCollection")
|
||||
&& File.Exists(Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
$"{Path.GetFileNameWithoutExtension(x)}.dll")))
|
||||
.ToList()
|
||||
.ForEach(path => c.IncludeXmlComments(path));
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseUnoFrameworkFiles();
|
||||
app.MapFallbackToFile("index.html");
|
||||
|
||||
app.MapWeatherApi();
|
||||
app.UseStaticFiles();
|
||||
|
||||
await app.RunAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine("Application terminated unexpectedly");
|
||||
Console.Error.WriteLine(ex);
|
||||
#if DEBUG
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user