Deadman Mersh
MediatR pipeline problem: One Notification to three different handlers based on notification
I'm dead stuck on a problem. I'm working on a project and instead of looping through a bunch of if statements or switches to get the correct handler. I want to direct the notification to publish to the correct handler based on the property passed through.
So say
public class UpdateLogger : INotification {
public Logger Message { get; set; }
}
public class UpdateLogger1Handler : INotification<UpdateLogger> {
// Logic here
}
public class UpdateLogger2Handler : INotification<UpdateLogger> {
// Logic here
}
public class UpdateLogger3Handler : INotification<UpdateLogger> {
// Logic here
}
And lets say Logger has a property like LoggerId that designates basically which of these 3 handlers goes to what
Bad design? Possible? The idea is that later on, all you'd have to do is add in a new handler to INotification<UpdateLogger> for a different publish.
15 replies