From d8242ebc571b1caa2e8e26b038e9d0c705defa05 Mon Sep 17 00:00:00 2001 From: Jason Webb Date: Thu, 2 May 2024 17:41:40 -0600 Subject: [PATCH] Extended CQRS DI interface --- Build/Build.cs | 2 +- .../CqrsBuilderExtensions.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Build/Build.cs b/Build/Build.cs index d25c01f2..ad209bb3 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -135,7 +135,7 @@ protected override void OnBuildInitialized() { Log.Information("Generating NuGet packages for projects in solution"); int commitNum = 0; - string NuGetVersionCustom = "2.0.0.875"; + string NuGetVersionCustom = "2.0.0.876"; //if it's not a tagged release - append the commit number to the package version diff --git a/Src/RCommon.ApplicationServices/CqrsBuilderExtensions.cs b/Src/RCommon.ApplicationServices/CqrsBuilderExtensions.cs index e5a54e59..a25793ce 100644 --- a/Src/RCommon.ApplicationServices/CqrsBuilderExtensions.cs +++ b/Src/RCommon.ApplicationServices/CqrsBuilderExtensions.cs @@ -36,6 +36,13 @@ public static void AddQueryHandler(this ICqrsBui builder.Services.AddTransient, TQueryHandler>(); } + public static void AddQuery(this ICqrsBuilder builder) + where TQueryHandler : class, IQueryHandler + where TQuery : IQuery + { + builder.Services.AddTransient, TQueryHandler>(); + } + public static void AddCommandHandler(this ICqrsBuilder builder) where TCommandHandler : class, ICommandHandler where TCommand : ICommand @@ -43,5 +50,13 @@ public static void AddCommandHandler(this IC { builder.Services.AddTransient, TCommandHandler>(); } + + public static void AddCommand(this ICqrsBuilder builder) + where TCommandHandler : class, ICommandHandler + where TCommand : ICommand + where TResult : IExecutionResult + { + builder.Services.AddTransient, TCommandHandler>(); + } } }