c# - create nested class in runtime -


i have xml file structure

<graph>     <id>0</id>     <name>john</name>     <link>http://test.com</link> </graph> <graph>     <id>1</id>     <name>roger</name>     <link>http://test2.com</link> </graph> 

i want use reflection.emit class create 2 class first:

class {      int id;      string name;      string link } 

second:

class b{       list<a> graphs; } 

i read paper (introduction creating dynamic types reflection.emit) , can create class in runtime problem using (a) in runtime class(b) , have 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 confusion typeof(list<tp>) ?????? error ocurred var myclass2 = mcb1.createobject(new string[1] {"graphs"}, new type[1]{typeof(list<tp>)}); //set value of class , 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 


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -