To construct a generic type with dynamic type parameters, you need to start with the generic type definition, and call
MakeGenericType[
^]:
Type myclassType = myclass.GetType();
Type listOfMyClass = typeof(List<>).MakeGenericType(myclassType);
var myclass2 = MCB1.CreateObject(new string[] { "graphs" }, new Type[] { listOfMyClass });
To create an instance of the list and add objects to it, use the non-generic
IList
interface:
var graphs = (IList)Activator.CreateInstance(listOfMyClass);
Type myclass2Type = myclass2.GetType();
object b = Activator.CreateInstance(myclass2Type);
myclass2Type.GetProperty("graphs").SetValue(b, graphs);
object a = Activator.CreateInstance(myclassType);
myclassType.GetProperty("id").SetValue(a, 0);
myclassType.GetProperty("name").SetValue(a, "Joh");
myclassType.GetProperty("link").SetValue(a, "http://test.com");
graphs.Add(a);