I have a Dictionary to map a certain type to a certain generic object for that type. For example:
typeof(LoginMessage) maps to MessageProcessor
To convert any type object to a generic type T, the trick is to first assign to an object of any higher type then cast that to the generic type.
T
object temp = otherTypeObject; T result = (T)temp;