First Commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using ADS.Helpers.NotifyCenter.Abstractions;
|
||||
using ADS.Helpers.NotifyCenter.Models;
|
||||
using ADS.Helpers.NotifyCenter.Providers;
|
||||
using ADS.Helpers.NotifyCenter.Providers.Smtp;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace ADS.Helpers.NotifyCenter.Extensions;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddAdsNotifyCenter(this IServiceCollection services)
|
||||
{
|
||||
services.AddOptions<NotifyCenterOptions>();
|
||||
services.AddSingleton<INotifyCenter, NotifyCenter>();
|
||||
|
||||
// Default settings provider (replace later with tenant-aware provider)
|
||||
services.AddSingleton<InMemoryNotificationSettingsProvider>();
|
||||
services.AddSingleton<INotificationSettingsProvider>(sp => sp.GetRequiredService<InMemoryNotificationSettingsProvider>());
|
||||
|
||||
// Providers
|
||||
services.AddSingleton<INotificationProvider, SmtpNotificationProvider>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
// Helper to configure SMTP quickly when using InMemoryNotificationSettingsProvider
|
||||
public static IServiceCollection ConfigureAdsSmtp(this IServiceCollection services, SmtpOptions options, string? tenantId = null)
|
||||
{
|
||||
var sp = services.BuildServiceProvider();
|
||||
var mem = sp.GetRequiredService<InMemoryNotificationSettingsProvider>();
|
||||
mem.Set(options, tenantId);
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user