Installation
Install AlmightyShogun.Utils in applications or packages that need the shared helper APIs directly. The package targets net10.0 and depends on the Microsoft configuration, options, and dependency-injection abstractions.
sh
dotnet add package AlmightyShogun.UtilsDependencies
Package references
Microsoft.Extensions.Configuration.Abstractions10.0.11— providesIConfigurationSectionfor options binding.Microsoft.Extensions.Configuration.Binder10.0.11— binds configuration sections to strongly typed options.Microsoft.Extensions.DependencyInjection.Abstractions10.0.11— providesIServiceCollectionand service lifetime types.Microsoft.Extensions.Options10.0.11— provides the options infrastructure.Microsoft.Extensions.Options.ConfigurationExtensions10.0.11— connects options to configuration binding.Microsoft.Extensions.Options.DataAnnotations10.0.11— enables data-annotation validation for configured options.
Usage
The package registers nothing at startup. Its IServiceCollection extensions are called from startup code once the namespace is imported, its TryDeserialize and DeserializeAsync extensions hang off string and Stream instead, and the ConsoleUtils and TypeDiscovery helpers are static and called wherever they are needed:
csharp
using AlmightyShogun.Utils;
using Microsoft.Extensions.DependencyInjection;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services
.AddConfiguration<ImportSettings>(
builder.Configuration.GetSection("Import")
)
.RegisterOnInherit<IImportStep>(ServiceLifetime.Transient)
.AddService<NotificationsRegistry>();