Initial use of Unity V3-Prepare for converting my. NET project from simple three-tier architecture to IOC

Source: Internet
Author: User

Due to my limited expression ability, in order to avoid unnecessary mistakes, this article will not involve IOC and DI, just describe the use of the new version of Unity 3 (non-Unity 3D, if you want to see Unity 3D, please leave immediately. Otherwise, you can't blame it for making money here ")


Popular IoC framework, the latest version is Unity v3.

 

Search for "Unity" in the pop-up window ",

After installation, you can determine whether to use Unity for projects in the solution. If you select or deselect this check box.

Of course, you can also download and reference it directly on the official website, which is also a common method.

 

[Coding] My Code contains an interface (IRegionFormat) three classes (DefaultRegionFormat,
DayMonthYearRegionFormat, MonthDayYearRegionFormat), and a class Program containing the Main method.

FormatName {time. ToString ({time. ToString (MonthDayYearRegionFormat ({time. ToString (One interface has three Main classes (= container. resolve <IRegionFormat >=< IRegionFormat, DefaultRegionFormat >== section. configure (container, <IRegionFormat >=); container. registerInstance (),); WriteFormat (container. resolve <IRegionFormat> (format! =Class Program containing the Main methodConfiguration File app. config

If the Code has comments, do not pull it.
[Note]1. the class of the injected interface object contains the constructor, And the constructor contains the parameter types not injected (such as string, if you have to ask which other types are, I don't know either, but there is no error when only the object type is used as the constructor parameter). "RegisterInstance" is required, as shown in the ParameterUnity method in the Program class.

2. The configuration file is in XML format and case sensitive.

3. Unity 3 help documentation: http://msdn.microsoft.com/en-us/library/dn170416.aspx

Complex address: http://unity.codeplex.com/

Related Article

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.