using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using StellaOps.Infrastructure.Postgres;
using StellaOps.Infrastructure.Postgres.Options;
using StellaOps.Notify.Storage.Postgres.Repositories;
namespace StellaOps.Notify.Storage.Postgres;
///
/// Extension methods for configuring Notify PostgreSQL storage services.
///
public static class ServiceCollectionExtensions
{
///
/// Adds Notify PostgreSQL storage services.
///
/// Service collection.
/// Configuration root.
/// Configuration section name for PostgreSQL options.
/// Service collection for chaining.
public static IServiceCollection AddNotifyPostgresStorage(
this IServiceCollection services,
IConfiguration configuration,
string sectionName = "Postgres:Notify")
{
services.Configure(sectionName, configuration.GetSection(sectionName));
services.AddSingleton();
// Register repositories
services.AddScoped();
services.AddScoped();
return services;
}
///
/// Adds Notify PostgreSQL storage services with explicit options.
///
/// Service collection.
/// Options configuration action.
/// Service collection for chaining.
public static IServiceCollection AddNotifyPostgresStorage(
this IServiceCollection services,
Action configureOptions)
{
services.Configure(configureOptions);
services.AddSingleton();
// Register repositories
services.AddScoped();
services.AddScoped();
return services;
}
}