From 6d7421a32bd559e808e594b9330cd1dd7ed4cffa Mon Sep 17 00:00:00 2001 From: Maxwell Weru Date: Tue, 21 Nov 2023 19:47:55 +0300 Subject: [PATCH] Apply `IEventBusConfigurator` instances in reverse (#568) --- .../DependencyInjection/EventBusConfigureOptions.cs | 4 ++-- src/Tingle.EventBus/EventBus.cs | 2 +- .../Transports/EventBusTransportConfigureOptions.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tingle.EventBus/DependencyInjection/EventBusConfigureOptions.cs b/src/Tingle.EventBus/DependencyInjection/EventBusConfigureOptions.cs index d5fe888c..62905efd 100644 --- a/src/Tingle.EventBus/DependencyInjection/EventBusConfigureOptions.cs +++ b/src/Tingle.EventBus/DependencyInjection/EventBusConfigureOptions.cs @@ -27,7 +27,7 @@ public EventBusConfigureOptions(IHostEnvironment environment, IEnumerable public void Configure(EventBusOptions options) { - foreach (var cfg in configurators) + foreach (var cfg in configurators.Reverse()) { cfg.Configure(options); } @@ -88,7 +88,7 @@ public void PostConfigure(string? name, EventBusOptions options) var registrations = options.Registrations.Values.ToList(); foreach (var evr in registrations) { - foreach (var cfg in configurators) + foreach (var cfg in configurators.Reverse()) { cfg.Configure(evr, options); } diff --git a/src/Tingle.EventBus/EventBus.cs b/src/Tingle.EventBus/EventBus.cs index 3e28bd3b..0f69bb78 100644 --- a/src/Tingle.EventBus/EventBus.cs +++ b/src/Tingle.EventBus/EventBus.cs @@ -242,7 +242,7 @@ internal EventRegistration GetOrCreateRegistration() // at this point, the registration does not exist; // create it and pass it through all the configurators. var registration = new EventRegistration(et); - foreach (var cfg in configurators) + foreach (var cfg in configurators.Reverse()) { cfg.Configure(registration, options); } diff --git a/src/Tingle.EventBus/Transports/EventBusTransportConfigureOptions.cs b/src/Tingle.EventBus/Transports/EventBusTransportConfigureOptions.cs index f2373f40..8bb5822a 100644 --- a/src/Tingle.EventBus/Transports/EventBusTransportConfigureOptions.cs +++ b/src/Tingle.EventBus/Transports/EventBusTransportConfigureOptions.cs @@ -56,7 +56,7 @@ public virtual void Configure(string? name, TOptions options) /// protected virtual void Configure(IConfiguration configuration, TOptions options) { - foreach (var cfg in configurators) + foreach (var cfg in configurators.Reverse()) { cfg.Configure(configuration, options); }