Version of Unity Application Block released in March 12

Source: Internet
Author: User

In March 12, unity released a version earlier than the official release. This version provides the installer and a configuration API for dependency injection implementation: setter injection. In the previous version, [dependency] is required for property injection. This design unity will intrude into your components. You can use configuringinjection.

For example, stoplightpresenter depends on stoplight and stoplightschedule. You can tag [dependency] In the attribute or remove this tag, and then configure the API in unitycontainer by configuring the following:

Public class stoplightpresenter
{
Private stoplight;
Private stoplightschedule schedule;

// [Dependency]
Public stoplight
{
Get {return stoplight ;}
Set {stoplight = value ;}
}

// [Dependency]
Public stoplightschedule schedule
{
Get {return schedule ;}
Set {Schedule = value ;}
}

Private istoplightview view;

......

}

The configuration code is as follows:

Iunitycontainer Container = new unitycontainer ()
. Addnewextension <simpleeventbrokerextension> ()
. Registertype <ilogger, tracelogger> ()
. Registertype <istoplighttimer, realtimetimer> ();
Container. Configure <injectedmembers> ()
. Configureinjectionfor <stoplight. Logic. stoplight> (
New injectionproperty ("logger ")
);

Container. Configure <injectedmembers> ()
. Configureinjectionfor <stoplightpresenter> (
New injectionproperty ("stoplight "),
New injectionproperty ("Schedule ")
);

Although the development of the Unity Application Block is not long, it is mainly based on the development of objectbuilder that emerged from enterprise class library 2.0. The next Microsoft Enterprise Library version V4-injection of Preset support dependency. Dependency injection is provided by containers independently or as part of the database. You need to learn more about the unity Application Block. You can refer to articles about terrylee, doriandeng, and overred in the garden:

Terrylee's unity Application Block

Dependency injection container unity Application Block (1): Quick Start to dependency injection container (Unity) preview in Enterprise Library 4.0

Doriandeng unity

Use Unity (1): Introduction to unity Application Block containers

Use Unity (2): Configure unity, read configuration information, and obtain objects

Use unity Application Block (3): understand and use the dependency injection key

Unity Feb 26 weekly drop

Overred ① Net Framework

Dependency injection container unity Application Block (2): Spring of Unity

By the way, you can also learn English:

Unity dependency injection IOC screencast

Unity IOC and ASP. net mvc Framework-dependency injection of controllers

Unity nested containers-iunityparentcontainer and createchildcontainer

Unity IOC-February 26 weekly drop-lifetimemanagers teardown extensions and idisposable

Using unity and the ASP. net mvc preview 2


 

 

 

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.