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

使用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>


你可能感兴趣的:(SPRING.NET 1.3.2 学习7--使用外部对象和内部对象)