I'm trying to put together a 'generic' subscriber that I can (re)use with Azure ServiceBus
.
But I'm stuck as follows; my code once stripped of non essential parts looks like this.
Subscribing.Client.OnMessage((recdMessage =>
{
var msgBody = recdMessage.GetBody<myClass>();
}, options);
I want my msgBody
to be of the type that has been serialised into the body of the message.
Indeed if myClass
were to be something like TelephonyEventMessage
and the message received was of that type then my msgBody
would be a correctly instantiated/rehydrated object of that type.
But although I can use recdMessage
. ContentType to get the string name of the class in that message.... I just cant figure what I need to put in myClass
above.
I'm at the end of my knowledge now and no amount of searches seems to look like an answer for me. Do I need to add a specific version for every type that may exist in my messages?