首页 > 代码库 > Spring.Net

Spring.Net

<?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>An example that demonstrates simple IoC features.</description>

<object name="UserInfoBLL" type="SpringNet.UserInfoBLL, SpringNet">
<constructor-arg index="0" value="http://www.mamicode.com/男"/>
<property name="Name" value="http://www.mamicode.com/张三"/>
<property name="Per" ref="refPerson"/>
</object>

<object name="refPerson" type="SpringNet.Person, SpringNet">
<property name="Age" value="http://www.mamicode.com/16"/>
</object>

</objects>
</spring>
</configuration>

 

private void button1_Click(object sender, EventArgs e)
{
//先把三个核心文件跟一个Logging文件复制到Lib文件夹下,然后添加引用,根据帮助文档修改配置文件
IApplicationContext ctx = ContextRegistry.GetContext();
IUserInfoBLL userInfo = (IUserInfoBLL)ctx.GetObject("UserInfoBLL");
MessageBox.Show(userInfo.ShowMsg("你好"));
}

Spring.Net