Skip to content

Commit 7fc68b4

Browse files
Merge pull request dotnet-architecture#818 from erikpique/feature/645
[BUG] When subscribing more than 1 different event handlers for the s…
2 parents 06de1b6 + 6811112 commit 7fc68b4

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/BuildingBlocks/EventBus/EventBus/InMemoryEventBusSubscriptionsManager.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
2-
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
3-
using System;
1+
using System;
42
using System.Collections.Generic;
53
using System.Linq;
6-
using System.Reflection;
7-
using System.Text;
4+
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
5+
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
86

97
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
108
{
@@ -37,8 +35,13 @@ public void AddSubscription<T, TH>()
3735
where TH : IIntegrationEventHandler<T>
3836
{
3937
var eventName = GetEventKey<T>();
38+
4039
DoAddSubscription(typeof(TH), eventName, isDynamic: false);
41-
_eventTypes.Add(typeof(T));
40+
41+
if (!_eventTypes.Contains(typeof(T)))
42+
{
43+
_eventTypes.Add(typeof(T));
44+
}
4245
}
4346

4447
private void DoAddSubscription(Type handlerType, string eventName, bool isDynamic)

0 commit comments

Comments
 (0)