From 79e7302690bf37f47e373cff91055250516285a1 Mon Sep 17 00:00:00 2001 From: Koen Metsu Date: Wed, 8 Jan 2025 14:45:24 +0100 Subject: [PATCH] refactor: register event types explicitly now they're in another assembly --- .../Infrastructure/Extensions/MartenExtensions.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/MartenExtensions.cs b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/MartenExtensions.cs index 4f2e392e3..1800da91a 100644 --- a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/MartenExtensions.cs +++ b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/MartenExtensions.cs @@ -1,6 +1,7 @@ namespace AssociationRegistry.Admin.Api.Infrastructure.Extensions; using Adapters.VCodeGeneration; +using Events; using Formats; using GrarConsumer; using GrarConsumer.Kafka; @@ -20,6 +21,7 @@ using Vereniging; using Weasel.Core; using Wolverine.Marten; +using IEvent = Events.IEvent; public static class MartenExtensions { @@ -54,6 +56,12 @@ public static IServiceCollection AddMarten( opts.Events.MetadataConfig.EnableAll(); opts.Events.AppendMode = isDevelopment ? EventAppendMode.Rich : EventAppendMode.Quick; + opts.Events.AddEventTypes( typeof(IEvent).Assembly + .GetTypes() + .Where(t => typeof(IEvent) + .IsAssignableFrom(t) && !t.IsAbstract && t.IsClass) + .ToList()); + opts.Listeners.Add( new HighWatermarkListener(serviceProvider.GetRequiredService()));