SPRING.NET 1.3.2 学习7--使用外部对象和内部对象

来源:互联网 发布:红旗linux桌面版 编辑:程序博客网 时间:2024/05/01 14:17

使用ref标签来使用外部对象

定义外部对象:

<!-- in the parent context --><object id="AccountService" type="MyApp.SimpleAccountService, MyApp">  <!-- insert dependencies as required as here --></object>
使用外部对象:

<!-- in the child (descendant) context --><object id="AccountService" <-- notice that the name of this object is the same as the name of the 'parent' object        type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">  <property name="target">    <ref parent="AccountService"/> <-- notice how we refer to the parent object -->  </property>  <!-- insert other configuration and dependencies as required as here --></object>
使用内部对象

<object id="outer" type="...">  <!-- Instead of using a reference to target, just use an inner object -->   <property name="target">     <object type="ExampleApp.Person, ExampleApp">       <property name="name" value="Tony"/>       <property name="age" value="51"/>     </object>  </property></object>


原创粉丝点击