Skip to content

Commit

Permalink
fix(is): LicenseUsageSummary resolution
Browse files Browse the repository at this point in the history
Fixed usage in the main host of the LicenseUsageSummary so that it is resolved at shutdown properly.
  • Loading branch information
josephdecock committed Jan 7, 2025
1 parent 1756170 commit 57eaaeb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions hosts/main/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.
#pragma warning disable IDE0058 // Expression value is never used

using Duende.IdentityServer.Licensing;
using IdentityServerHost;
Expand Down Expand Up @@ -38,12 +39,14 @@
.ConfigureServices()
.ConfigurePipeline();

var usage = app.Services.GetRequiredService<LicenseUsageSummary>();
app.Lifetime.ApplicationStopping.Register(() =>
{
var usage = app.Services.GetRequiredService<LicenseUsageSummary>();
Console.Write(Summary(usage));
Console.ReadKey();
});

app.Run();

Console.Write(Summary(usage));
Console.ReadKey();
}
catch (Exception ex)
{
Expand All @@ -55,7 +58,7 @@
Log.CloseAndFlush();
}

string Summary(LicenseUsageSummary usage)
static string Summary(LicenseUsageSummary usage)
{
var sb = new StringBuilder();
sb.AppendLine("IdentityServer Usage Summary:");
Expand All @@ -67,4 +70,3 @@ string Summary(LicenseUsageSummary usage)

return sb.ToString();
}

0 comments on commit 57eaaeb

Please sign in to comment.