using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using StellaOps.Infrastructure.Postgres.Options;
namespace StellaOps.Infrastructure.Postgres;
///
/// Extension methods for configuring PostgreSQL infrastructure services.
///
public static class ServiceCollectionExtensions
{
///
/// Adds PostgreSQL infrastructure options from configuration.
///
/// Service collection.
/// Configuration root.
/// Configuration section name for PostgreSQL options.
/// Service collection for chaining.
public static IServiceCollection AddPostgresOptions(
this IServiceCollection services,
IConfiguration configuration,
string sectionName = "Postgres")
{
services.Configure(configuration.GetSection(sectionName));
return services;
}
///
/// Adds PostgreSQL infrastructure with the specified options.
///
/// Service collection.
/// Options configuration action.
/// Service collection for chaining.
public static IServiceCollection AddPostgresInfrastructure(
this IServiceCollection services,
Action configureOptions)
{
services.Configure(configureOptions);
return services;
}
}