Replies: 2 comments 1 reply
-
We also don't know the message type before hand. There there would still need some reflection to go from the general one to the concrete. We have also some filters that are used to deserialize and filter on message body and message context, plus, the actual processing method also has the concrete message type in its method. |
Beta Was this translation helpful? Give feedback.
-
I think indeed that in this case, you'll need to apply some reflection. However, If we can find a way to improve that first step, that might already be good, as I do not like to rely on getting properties / fields via reflection of types that we do not own. It's just too fragile, as we are not in control / we do not know when the implementation of that type changes. |
Beta Was this translation helpful? Give feedback.
-
Not an idea for a new feature, but an idea for a possible improvement.
As mentionned in this PR #260 , the code to retrieve registered
IMessageHandler
implementations is not that stable. We should find a way to improve this.@stijnmoreels's comment copied from the mentionned PR:
I was wondering if we couldn't work around this without using reflection.
Maybe it is an idea to introduce a non-generic interface (empty)
IMessageHandler
. TheIMessageHandler<,>
would then derive from that non-genericIMessageHandler
interface, like this:The code for retrieving registered message-handlers could then work on retrieving types that are assignable from the base-interface
IMessageHandler
.Once we have retrieved those types, then we need of course an additional filter: we only want to take into consideration those types that are also assignable to the IMessageHandler interface which declares type parameters.
Beta Was this translation helpful? Give feedback.
All reactions