Set of my helpers
Register service both as TService and TImplementation with transient lifetime
IServiceCollectionservices=new();services.AddTypeAndImplementation<IInterface,Service>();Wrapper for BetterHostedServices.CriticalBackgroundService
Allows you to forget about IApplicationEnder
classService:NotEndingCriticalBackgroundService{protectedoverrideTaskExecute(CancellationTokentoken){// Do stuff}protectedoverridevoidOnError(Exceptionexception){// Handle exception}}Allows you to fluent log exception before throw it. Default LogLevel is Critical
thrownewArgumentException().LogExceptionMessage(logger);thrownewArgumentException().LogExceptionMessage(logger,LogLevel.Debug);Overload that take Action for more useful calls chaining
services.AddOptions<CustomizableField.Configuration>(builder =>builder.BindConfiguration(CustomizableField.Configuration.SectionName).Validate(CustomizableField.Configuration.Validate)).AddOptions<AiPlayer.AiPlayerBehaviour>(builder =>builder.BindConfiguration(AiPlayer.AiPlayerBehaviour.SectionName));