0

I am using Unity in my webapplication project. I also have other library project ex. Presentation, Data. My Unity configuration is in web.config file.

My problem is I can not use dependency injection from one libary to another. I want to inject property DataService from library Data in library Presentation in class PlayViewPresenter.

This is section fomr configuration file:

<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
        <alias alias="IDataService" type="Data.IDataService, Data"/>
        <alias alias="DataService" type="Data.DataService, Data"/>
        <alias alias="PlayViewPresenter" type="Presentation.PlayViewPresenter, Presentation"/>
        <assembly name="Data"/>
        <assembly name="Presentation"/>
        <namespace name="Data"/>
        <namespace name="Presentation"/>

        <container name="application">
        </container>

        <container name="session">
            <register type="IDataService" mapTo="DataService">
                <lifetime type="TransientLifetimeManager"/>
            </register>

        </container>
    </unity>
4

1 回答 1

0

我发现我不见了:

var container = Session["container"] as IUnityContainer; var presenter = container.Resolve();

于 2012-07-31T08:11:43.890 回答