[BUG] When subscribing more than 1 different event handlers for the same event type #645

https://github.com/dotnet-architecture/eShopOnContainers/issues/645
This commit is contained in:
Erik Pique 2018-10-09 10:13:20 +02:00
parent bb8dd63e69
commit 681111221f

View File

@ -1,10 +1,8 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using System;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using System.Text; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
{ {
@ -37,9 +35,14 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
where TH : IIntegrationEventHandler<T> where TH : IIntegrationEventHandler<T>
{ {
var eventName = GetEventKey<T>(); var eventName = GetEventKey<T>();
DoAddSubscription(typeof(TH), eventName, isDynamic: false); DoAddSubscription(typeof(TH), eventName, isDynamic: false);
if (!_eventTypes.Contains(typeof(T)))
{
_eventTypes.Add(typeof(T)); _eventTypes.Add(typeof(T));
} }
}
private void DoAddSubscription(Type handlerType, string eventName, bool isDynamic) private void DoAddSubscription(Type handlerType, string eventName, bool isDynamic)
{ {