I have a Dictionary to map a certain type to a certain generic object for that type. For example:
typeof(LoginMessage) maps to MessageProcessor
I had a similar problem. I have a class;
Action
which has a property of type T.
How do I get the property when I don't know T? I can't cast to Action<> unless I know T.
SOLUTION:
Implement a non-generic interface;
public interface IGetGenericTypeInstance
{
object GenericTypeInstance();
}
Now I can cast the object to IGetGenericTypeInstance and GenericTypeInstance will return the property as type object.