I have this object that I'm serializing and sending to a server over TCP/IP and I need to deserialize it and fire it off in a message of the right type. I'm using .net 4.
The problem is that the object could be of several different types and the messenger needs to know the type of what it's sending. What I want to do is to send a string or Type object along that will specify what the main object's type is. Right now I'm doing this, but it only works for one type:
public void generic_Obj(Object obj)
{
//Entity is a class that I define elsewhere
//I'm using the Galasoft MVVM Light messenger
Messenger.Default.Send<Entity>((Entity)obj, "token");
}
I want to do something like this using reflection:
public void gen_Obj(Object obj, Type genType, string token)
{
//this doesn't work btw
Messenger.Default.Send<genType>((genType)obj, token);
}
I've tried all different methods of dynamic casting and such using reflection, some of them worked, but my real problem is finding something to put in between those <> brackets in the messenger call.