zoukankan      html  css  js  c++  java
  • Spring.NET 配置

    创建内部类对象

    <object id="exampleObject" type="Examples.ExampleObject+Person, ExamplesLibrary"/>

    通过工厂类的静态方法创建对象

    <object id="exampleObject"
          type="Examples.ExampleObjectFactory, ExamplesLibrary"
          factory-method="CreateInstance"/>

    通过工厂类对象的方法创建对象

    <object id="exampleFactory" type="..."></object>
    
    <object id="exampleObject"
          factory-method="CreateInstance"
          factory-object="exampleFactory"/>

     

    普通注射

    <object id="myConnection" type="System.Data.SqlClient.SqlConnection">
          <property
              name="ConnectionString"
              value="Integrated Security=SSPI;database=northwind;server=mySQLServer"/>
    </object>
     

    构造方法注射

    <object name="exampleObject" type="SimpleApp.ExampleObject, SimpleApp">
      <constructor-arg name="years" value="7500000"/>
      <constructor-arg name="ultimateAnswer" value="42"/>
    </object>

     

    属性引用其他对象

    <object id="theTargetObject" type="..."></object>
    
    <object id="theClientObject" type="...">
      <property name="targetName"> 
        <idref object="theTargetObject"/> 
      </property>
    </object>

    或者

    <object id="theTargetObject" type="..."> 
      . . .
    </object>
    
    <object id="theClientObject" type="...">
      <property name="targetName" value="theTargetObject"/> 
    </object>

    Inline对象

    <object id="outer" type="...">
      <property name="target"> 
        <object type="ExampleApp.Person, ExampleApp"> 
          <property name="name" value="Tony"/> 
          <property name="age" value="51"/> 
        </object>
      </property>
    </object>
     

    注射容器

    <object id="moreComplexObject" type="Example.ComplexObject">
          <!--
          results in a call to the setter of the SomeList (System.Collections.IList) property
          -->
          <property name="SomeList">
              <list>
                  <value>a list element followed by a reference</value>
                  <ref object="myConnection"/>
              </list>
          </property>
          <!--
          results in a call to the setter of the SomeDictionary (System.Collections.IDictionary) property
          -->
          <property name="SomeDictionary">
              <dictionary>
                  <entry key="a string => string entry" value="just some string"/>
                  <entry key-ref="myKeyObject" value-ref="myConnection"/>
              </dictionary>
          </property>
          <!--
          results in a call to the setter of the SomeNameValue (System.Collections.NameValueCollection) property
          -->
          <property name="SomeNameValue">
              <name-values>
                  <add key="HarryPotter" value="The magic property"/>
                  <add key="JerrySeinfeld" value="The funny (to Americans) property"/>
              </name-values>
          </property>
          <!-- 
          results in a call to the setter of the SomeSet (Spring.Collections.ISet) property 
          -->
          <property name="someSet">
              <set>
                  <value>just some string</value>
                  <ref object="myConnection"/>
              </set>
          </property>
      </object>
     
    
    
    
    

    引用对象的属性

    <object name="person" type="Spring.Objects.TestObject, Spring.Core.Tests">
      <property name="age" value="20"/>
      <property name="spouse">
        <object type="Spring.Objects.TestObject, Spring.Core.Tests">                      
          <property name="age" value="21"/>
        </object>
      </property>          
    </object>
            
    // will result in 21, which is the value of property 'spouse.age' of object 'person'        
    <object name="theAge" type="Spring.Objects.Factory.Config.PropertyRetrievingFactoryObject, Spring.Core">
      <property name="TargetObject" ref="person"/>
      <property name="TargetProperty" value="spouse.age"/>
    </object>
     

    static属性

    <object id="currentUICulture" 
            type="Spring.Objects.Factory.Config.PropertyRetrievingFactoryObject, Spring.Core">
      <property name="StaticProperty">
          <value>System.Globalization.CultureInfo.CurrentUICulture, Mscorlib</value>
      </property>
    </object>
  • 相关阅读:
    013.ES6 -对象字面量增强型写法
    012. ES6
    011. ES6 语法
    10. 9. Vue 计算属性的setter和getter 以及 计算属性的缓存讲解
    4. Spring MVC 数据响应方式
    3. SpringMVC 组件解析
    9. Vue 计算属性
    【洛谷 2984】给巧克力
    【洛谷 1821】捉迷藏 Hide and Seek
    【洛谷 1821】银牛派对Silver Cow Party
  • 原文地址:https://www.cnblogs.com/mrfangzheng/p/1275613.html
Copyright © 2011-2022 走看看