From a38e8f9680a2ba4d97251b90c03c7101236b5eb4 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 28 Jul 2026 14:33:36 +0200 Subject: [PATCH] Add Action overload to RabbitMQ DI registration --- .../DependencyInjection.cs | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/infrastructure/DigitalData.MessagingService.RabbitMQ/DependencyInjection.cs b/src/infrastructure/DigitalData.MessagingService.RabbitMQ/DependencyInjection.cs index 45514f4..842f405 100644 --- a/src/infrastructure/DigitalData.MessagingService.RabbitMQ/DependencyInjection.cs +++ b/src/infrastructure/DigitalData.MessagingService.RabbitMQ/DependencyInjection.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using System; namespace DigitalData.MessagingService.RabbitMQ { @@ -8,14 +9,31 @@ namespace DigitalData.MessagingService.RabbitMQ /// public static class DependencyInjection { + private static IServiceCollection AddDefaultServices(this IServiceCollection services) + { + services.AddSingleton(); + return services; + } + /// /// Adds Infrastructure layer services to the DI container /// - public static IServiceCollection AddRabbitMqConnectionFactory( - this IServiceCollection services, - IConfiguration configuration) + public static IServiceCollection AddRabbitMqConnectionFactory(this IServiceCollection services, Action configure) { - services.AddSingleton(); + services.AddDefaultServices(); + + // --- RabbitMQ Configuration --- + services.Configure(configure); + + return services; + } + + /// + /// Adds Infrastructure layer services to the DI container + /// + public static IServiceCollection AddRabbitMqConnectionFactory(this IServiceCollection services, IConfiguration configuration) + { + services.AddDefaultServices(); // --- RabbitMQ Configuration --- services.Configure( @@ -24,5 +42,4 @@ namespace DigitalData.MessagingService.RabbitMQ return services; } } - } \ No newline at end of file