I want to configure the spring.net in some other setting files like xml not through app.config. Is it possible to configure the spring.net in xml not in app.config file.if开发者_如何学Python yes how can i do it.
Yes, you can place your configuration in normal xml files. In the Spring.NET documentation, the following example is given:
services.xml
:
<objects xmlns="http://www.springframework.net">
<object id="PetStore" type="PetStore.Services.PetStoreService, PetStore">
<property name="AccountDao" ref="AccountDao"/>
<property name="ItemDao" ref="ItemDao"/>
<!-- additional collaborators and configuration for this object go here -->
</object>
<!-- more object definitions for services go here -->
</objects>
The file daos.xml
has a similar structure and contains definitions for ItemDao
and AccountDao
.
In code, you can create an instance of your container using the files services.xml
and daos.xml
as follows:
IApplicationContext context = new XmlApplicationContext("services.xml", "daos.xml")
精彩评论