Closed ValResnick closed 3 years ago
This is the expected behaviour. In your case you should be subscribing to IMessage
.
But i dont want to subscribe to IMessage, because i dont want to have different messages in one subscription.
Only the subscription for MyMessage should be "fired". Because that is the real type. I think you should use GetType in publish instead of typeof(T)?
Why not? You can simply do:
Calling GetType
is slow compared to the current solution. Once again the library is behaving as expected. It is not the intention of the library to do runtime type checking. That kind of specific behaviour can be done by yourself.
Well, then i could only register to the global hook and check every possible messsage there...
In a normal, non high performance, scenario the GetType call will not hurt.
Thanks for your feedback. I will use Reflection to call the "correct" publish method or i take a different Api.
Hi,
i think my issue is related to https://github.com/NimaAra/Easy.MessageHub/issues/11.
In my scenario, every message implements the interface IMessage. The problem is, that the type detection doesn't use the real type of an object to detect the subscription, instead it uses the compiled generic parameter T.
Example:
The message will not be recognized for my subscriptions, because of the type 'IMessage'. The only workarround i see, is to use reflection. Is it possible to change this behaviour?