IOC container AUTOFAC (iv)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.