.NET 10 solution for Ping, a Discord style chat app: Domain, Application and Infrastructure projects plus the Api host. SignalR for chat and presence, LiveKit for call tokens, EF Core on Postgres, S3 compatible storage for attachments, and OIDC auth shared with the Musify Zitadel instance. Includes the Compose stack for local development.
27 lines
818 B
C#
27 lines
818 B
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace Ping.Application.Configuration
|
|
{
|
|
public static class ConfigurationDependencyInjection
|
|
{
|
|
public static IServiceCollection AddValidatedOptions<T>(
|
|
this IServiceCollection services,
|
|
IConfiguration configuration,
|
|
string sectionName)
|
|
where T : class
|
|
{
|
|
services
|
|
.AddOptionsWithValidateOnStart<T>()
|
|
.Bind(configuration.GetRequiredSection(sectionName))
|
|
.ValidateDataAnnotations();
|
|
|
|
services.AddSingleton(serviceProvider =>
|
|
serviceProvider.GetRequiredService<IOptions<T>>().Value);
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|