From 2d515a7bec34797c30d0fa10aab9535dc5dcb2aa Mon Sep 17 00:00:00 2001 From: Jason Webb <46631010+JasonMWebb@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:23:21 -0700 Subject: [PATCH] Updates to DI and examples. --- Examples/Examples.sln | 2 -- Src/RCommon.EventHandling/EventHandlingBuilderExtensions.cs | 3 +++ Src/RCommon.Persistence/PersistenceBuilderExtensions.cs | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Examples/Examples.sln b/Examples/Examples.sln index 212ef81f..d59cf860 100644 --- a/Examples/Examples.sln +++ b/Examples/Examples.sln @@ -111,8 +111,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.EventHandling.Medi EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CQRS", "CQRS", "{783F8A99-F164-42E3-BD7C-09D432D02DEE}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CQRS", "CQRS", "{D724588A-9236-4175-A337-53C4530CC5A7}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Experimental", "Experimental", "{6509FEEC-F46C-4B03-82D4-8F2D78896160}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.EventHandling.InMemoryEventBus", "EventHandling\Examples.EventHandling.InMemoryEventBus\Examples.EventHandling.InMemoryEventBus.csproj", "{86CE6DBE-418E-440B-9C27-58B00AFB2FCA}" diff --git a/Src/RCommon.EventHandling/EventHandlingBuilderExtensions.cs b/Src/RCommon.EventHandling/EventHandlingBuilderExtensions.cs index fd3c76a8..cedaffe1 100644 --- a/Src/RCommon.EventHandling/EventHandlingBuilderExtensions.cs +++ b/Src/RCommon.EventHandling/EventHandlingBuilderExtensions.cs @@ -27,6 +27,9 @@ public static IRCommonBuilder WithEventHandling(this IRCommonBuilder builder, // Event Bus builder.Services.AddSingleton(); + // Event Routing + builder.Services.AddTransient(); + // Event Handling Configurations var eventHandlingConfig = (T)Activator.CreateInstance(typeof(T), new object[] { builder }); actions(eventHandlingConfig); diff --git a/Src/RCommon.Persistence/PersistenceBuilderExtensions.cs b/Src/RCommon.Persistence/PersistenceBuilderExtensions.cs index 672e61b2..ceaa733f 100644 --- a/Src/RCommon.Persistence/PersistenceBuilderExtensions.cs +++ b/Src/RCommon.Persistence/PersistenceBuilderExtensions.cs @@ -1,10 +1,13 @@ using Microsoft.Extensions.DependencyInjection; using RCommon.Entities; +using RCommon.EventHandling; +using RCommon.EventHandling.Producers; using RCommon.Persistence; using RCommon.Persistence.Transactions; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; @@ -65,6 +68,7 @@ public static IRCommonBuilder WithPersistence(this I /// Updated instance of RCommon Configuration private static IRCommonBuilder WithChangeTracking(this IRCommonBuilder config) { + config.Services.AddTransient(); config.Services.AddScoped(); return config; }