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/