zoukankan      html  css  js  c++  java
  • spring.net使用

    1.方法

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    namespace SpringTest
    {
       public class Person:IPerson
        {
    
            #region IPerson 成员
    
            public void Actor(string msg)
            {
                MessageBox.Show(msg);
            }
    
            #endregion
        }
    }
    View Code

    2.接口

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace SpringTest
    {
       public interface IPerson
        {
            void Actor(string msg);
           
        }
    }
    View Code

    3.调用方式

    using Spring.Dao;
    using Spring.Data;
    using Spring.Context.Support;
    using Spring.Context;
    
    private void btnSpring_Click(object sender, EventArgs e)
    {
    IApplicationContext ctx = ContextRegistry.GetContext();
    IPerson ps = ctx.GetObject("Person") as IPerson;
    ps.Actor("spring");
    }
    View Code

     

    4.web.config配置

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <configSections>
        <sectionGroup name="spring">
          <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
          <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
        </sectionGroup>
      </configSections>
    
      <spring>
    
        <context>
          <resource uri="config://spring/objects" />
        </context>
    
        <objects xmlns="http://www.springframework.net">
          <description>一个简单的控制反转例子</description>
    
    
          <object id="Person" type="SpringTest.Person, SpringTest" />
    
    
        </objects>
    
      </spring>
    
    </configuration>
    View Code
  • 相关阅读:
    iphone那些事儿
    【转】我面试过最出色的项目主管,入职半年就离职了。
    net::ERR_ABORTED 404 (Not Found)
    四大名著
    测试心理状态
    typescript那些事儿
    flexbox父盒子flex-direction属性
    flexbox父盒子align-content属性
    flexbox父盒子flex-wrap属性
    flexbox父盒子align-items属性
  • 原文地址:https://www.cnblogs.com/qq4004229/p/3259686.html
Copyright © 2011-2022 走看看