I want to Instantiate a generic type from string and have done the following:
private static void APERAK(string content, PartyElement pe, bool reload)
{
Type t = typeof(Serializer<>).MakeGenericType(Type.GetType(GetMessageTypeVersion(content)));
Serializer<t> serializer = new Serializer<t>();
}
private static string GetMessageTypeVersion(string content)
{
//TODO
return "APERAK";
}
But in
Serializer<t> serializer = new Serializer<t>();
it says that "The type or namespace name 't' could not be found (are you missing a using directive or an assembly reference?)" before compiling. But I want to instantiate the Serializer based on the string found. How can I do this?