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="男"/>
<property name="Name" value="张三"/>
<property name="Per" ref="refPerson"/>
</object>

<object name="refPerson" type="SpringNet.Person, SpringNet">
<property name="Age" value="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("你好"));
}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。