PenningtonExtensions
Pennington.Infrastructure
DI and pipeline extensions that wire Pennington services into an ASP.NET Core host.
Methods
AddPennington
#public static IServiceCollection AddPennington(IServiceCollection services, Action<PenningtonOptions> configure)
Register all Pennington services.
Parameters
servicesIServiceCollectionconfigureAction<PenningtonOptions>
Returns
IServiceCollectionAddYamlContext
#public static IServiceCollection AddYamlContext(IServiceCollection services, YamlSerializerContext context)
Register a source-generated YamlSerializerContext so the types it covers deserialize without reflection (NativeAOT/trim-friendly). Types not covered by any registered context fall back to reflection. Satellite templates call this for their own front-matter records; end users call it for theirs.
Parameters
servicesIServiceCollectioncontextYamlSerializerContext
Returns
IServiceCollectionRunOrBuildAsync
#public static Task RunOrBuildAsync(WebApplication app, string[] args)
Runs the host: serves live (no verb), builds the static site (build), or runs a diagnostic command (diag <sub>). Everything flows through one System.CommandLine pipeline, so --help / --version work at the root and every subcommand. Build and diag run one-shot against a started in-memory host that is disposed afterward; serve hands off to RunAsync.
Parameters
appWebApplicationargsstring[]
Returns
TaskUseLocaleRouting
#public static WebApplication UseLocaleRouting(WebApplication app)
Adds locale detection and URL path rewriting middleware. Must be called MapRazorComponents so that Blazor routing sees the locale-stripped path (e.g., /gen-z/schedule becomes /schedule).
Called automatically by UsePennington when it hasn't been called yet, but at that point it is too late for Blazor endpoint routing. Sites that use @page directives with locale prefixes must call this explicitly.
Parameters
appWebApplication
Returns
WebApplicationUsePennington
#public static WebApplication UsePennington(WebApplication app)
Configure the Pennington middleware pipeline.
Parameters
appWebApplication
Returns
WebApplicationPennington.Infrastructure.PenningtonExtensions
namespace Pennington.Infrastructure;
/// DI and pipeline extensions that wire Pennington services into an ASP.NET Core host.
public class PenningtonExtensions
{
/// Register all Pennington services.
public static IServiceCollection AddPennington(IServiceCollection services, Action<PenningtonOptions> configure)
;
/// Register a source-generated YamlSerializerContext so the types it covers deserialize without reflection (NativeAOT/trim-friendly). Types not covered by any registered context fall back to reflection. Satellite templates call this for their own front-matter records; end users call it for theirs.
public static IServiceCollection AddYamlContext(IServiceCollection services, YamlSerializerContext context)
;
/// Runs the host: serves live (no verb), builds the static site (build), or runs a diagnostic command (diag <sub>). Everything flows through one System.CommandLine pipeline, so --help / --version work at the root and every subcommand. Build and diag run one-shot against a started in-memory host that is disposed afterward; serve hands off to RunAsync.
public static Task RunOrBuildAsync(WebApplication app, string[] args)
;
/// Adds locale detection and URL path rewriting middleware. Must be called MapRazorComponents so that Blazor routing sees the locale-stripped path (e.g., /gen-z/schedule becomes /schedule). Called automatically by UsePennington when it hasn't been called yet, but at that point it is too late for Blazor endpoint routing. Sites that use @page directives with locale prefixes must call this explicitly.
public static WebApplication UseLocaleRouting(WebApplication app)
;
/// Configure the Pennington middleware pipeline.
public static WebApplication UsePennington(WebApplication app)
;
}