1
1 classTest2 {3 4 PrivateIteacher _teacher;5 Privateistudent _student;6 PublicTest (iteacher tea, istudent stu)7 {8_teacher =tea;9_student =Stu;Ten } One}
2
1 classstudent:istudent2 {3 4 PublicStudent ()5 {6 inti =1;7 }8 9 Ten Public int Age One { A Get{Throw Newnotimplementedexception ();} - } -}
3
1 classTeacher:iteacher2 {3 4 PublicTeacher ()5 {6 intm =0;7 }8 Public int Age9 {Ten Get{Throw Newnotimplementedexception ();} One } A}
4
1_container. Registertype<istudent, Student> (NewContainerControlledLifetimeManager ());2_container. Registertype<iteacher, Teacher> (NewContainerControlledLifetimeManager ());3 4 varViewmodeltypename =string. Format (CultureInfo.InvariantCulture,"app5.test, APP5, version=1.0.0.0, Culture=neutral");5 varViewmodeltype =Type.GetType (viewmodeltypename);6 7_container. Resolve (Viewmodeltype);
The test class has not been registered
But when resolve the test class, the parameters in the test constructor are automatically resolve
That is, before the test constructor is called, the following actions are performed
1 _container. Resolve (isutdent);
2 _container. Resolve (Iteacher);
and pass the result as a constructor parameter to test
Note: If the parameter passed by the constructor in test is not registered, the resolve operation of the test class will error
About Regeisttype you can view http://www.cnblogs.com/50614090/archive/2012/02/01/2334866.html
Resolve value of constructors in type