Fixed more edge cases

This commit is contained in:
TheXamlGuy
2024-05-16 21:41:48 +01:00
parent 8c0436644a
commit 7f3c4c53cc
16 changed files with 93 additions and 33 deletions
+2 -1
View File
@@ -40,6 +40,7 @@ public class Mediator(IHandlerProvider handlerProvider,
handlerList = [];
handlers.Add(handlerType, handlerList);
}
handlerList.Add(handler);
}
}
@@ -48,7 +49,7 @@ public class Mediator(IHandlerProvider handlerProvider,
{
foreach (object? handler in handlerEntry.Value)
{
if (handler?.GetType().GetMethod("Handle") is MethodInfo handleMethod)
if (handler?.GetType().GetMethod("Handle", [messageType, typeof(CancellationToken)]) is MethodInfo handleMethod)
{
return await (Task<TResponse?>)handleMethod.Invoke(handler,
new object[] { message, cancellationToken })!;