AUTOFAC is a lightweight, dependency-injected framework, with a framework of the same type and spring.net,unity,castle.
A very depressing place to use AUTOFAC is that the server requires the Microsoft. NET Framework 4 KB2468871 to be installed. The address of the patch is: http://www.microsoft.com/zh-cn/download/confirmation.aspx?id=3556 if not installed, the running program will report the following error:
Specific information can be here to view: https://code.google.com/p/autofac/wiki/FrequentlyAskedQuestions
namespaceconsoleapplication3{classProgram {Static voidMain (string[] args) {Containerbuilder Builder=NewContainerbuilder (); Builder. Registertype<AutoFacManager>(); Builder. Registertype<Worker> (). As<iperson>(); using(IContainer container =Builder. Build ()) {Autofacmanager Manager= Container. Resolve<autofacmanager>(); Manager. Say (); } console.readkey (); } } Public InterfaceIPerson {voidSay (); } Public classWorker:iperson { Public voidSay () {Console.WriteLine ("I am a worker! "); } } Public classStudent:iperson { Public voidSay () {Console.WriteLine ("I am a student! "); } } Public classAutofacmanager {IPerson person; PublicAutofacmanager (IPerson myperson) { person=MyPerson; } Public voidSay () {person. Say (); } }}
IOC container AUTOFAC (iv)