i have a xml file with this structure
<graph>
<id>0</id>
<name>John</name>
<link>http://ift.tt/1FoqB17;
</graph>
<graph>
<id>1</id>
<name>Roger</name>
<link>http://ift.tt/1L6AyPG;
</graph>
i want use Reflection.Emit class for create two class first:
class A {
int id;
string name;
string link
}
second:
Class B{
List<A> graphs;
}
i read this paper (Introduction to Creating Dynamic Types with Reflection.Emit[^])and can create class A in runtime but the problem is using this (A) in another runtime class(B) and also have a List of A.
MyClassBuilder MCB=new MyClassBuilder("A");
var myclass = MCB.CreateObject(new string[3] { "id", "name", "link" }, new Type[3] { typeof(int), typeof(string), typeof(string) });
Type TP = myclass.GetType();
MyClassBuilder MCB1=new MyClassBuilder("B");
//Here is my confusion typeof(List<TP>) ?????? Error Ocurred
var myclass2 = MCB1.CreateObject(new string[1] {"graphs"}, new Type[1]{typeof(List<TP>)});
//set value of class A and work
object tp = Activator.CreateInstance(TP);
TP.GetProperty("id").SetValue(tp,0);
TP.GetProperty("name").SetValue(tp,"Joh");
TP.GetProperty("link").SetValue(tp,"http://test.com");
//set value of class B ??????
//add tp in graphs
Aucun commentaire:
Enregistrer un commentaire