31 lines
989 B
C#
31 lines
989 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Svrnty.CQRS.Events.Abstractions;
|
|
|
|
namespace Svrnty.CQRS.Events.RabbitMQ;
|
|
|
|
/// <summary>
|
|
/// Extension methods for registering RabbitMQ domain event publishing.
|
|
/// </summary>
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds RabbitMQ domain event publishing to the service collection.
|
|
/// </summary>
|
|
/// <param name="services">The service collection.</param>
|
|
/// <param name="configure">Optional configuration action for RabbitMQ options.</param>
|
|
/// <returns>The service collection for chaining.</returns>
|
|
public static IServiceCollection AddRabbitMqDomainEvents(
|
|
this IServiceCollection services,
|
|
Action<RabbitMqEventOptions>? configure = null)
|
|
{
|
|
if (configure != null)
|
|
{
|
|
services.Configure(configure);
|
|
}
|
|
|
|
services.AddSingleton<IDomainEventPublisher, RabbitMqDomainEventPublisher>();
|
|
|
|
return services;
|
|
}
|
|
}
|