I have a generic model called Message that has a string called route and a payload. What the payload actually is dependant on the route. So for instance if(Route == "Subscribe")
then payload is the subscribe model. if(Route == "Post")
then payload has the Post model. Is there anyway I can deserialize to a generic Message model like this:
class Message<T> {
string Route { get; set; }
T PayLoad { get; set; }
}
And my deserialization function creates Message correctly based on the route?