Using Spring.net in console application
来源:互联网 发布:windows官方镜像 编辑:程序博客网 时间:2024/05/16 10:07
- Download Spring.net in http://www.springframework.net/
- Install Spring.NET.exe
- Create a console application, and reference Spring.Core.dll.
- Add App.config to project, the content is as follows
<?xml version="1.0" encoding="utf-8" ?><configuration> <configSections> <sectionGroup name="spring"> <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/> </sectionGroup> </configSections> <spring> <context> <resource uri="spring.xml.config"/> </context> </spring></configuration>
- Program.cs as follows
namespace ConsoleApplication5{ class Program { static void Main(string[] args) { IApplicationContext context = ContextRegistry.GetContext(); Hello hello = (Hello)context.GetObject("hello"); System.Console.Out.WriteLine(hello.HelloWorld); System.Console.In.Read(); } } class Hello { private string helloworld; public string HelloWorld { get { return this.helloworld; } set { this.helloworld = value; } } }}
- Add spring.xml.config to project (set Copy always to output directory), the content is as follows
主程序中调用context.GetObject并传入"hello"参数,就会在这里查找相应的类,以其来创建实例,并根据配置给此实例的属性HelloWorld赋值。
<?xml version="1.0" encoding="utf-8" ?><objects xmlns="http://www.springframework.net"> <object id="hello" type="ConsoleApplication5.Hello"> <property name="HelloWorld" value="Hello!Welcome to Spring.Net World!"/> </object></objects>
- Run application.
- Spring.net的核心思想是Ioc,依赖文件中的配置来决定程序的执行走向。
- Using Spring.net in console application
- Using a Console in Winform Application
- Effective testing in console application
- C# Clipboard in Console Application
- C# Clipboard in Console Application
- Using the Web Service Callbacks in the .NET Application
- Integrating OpenID in an ASP.NET MVC Application using DotNetOpenAuth
- Using Theme in an Application
- Using Theme in an Application
- using mysql in java application
- Using SQLite in Android Application
- Winsock frame in Win32 console application
- GUI application run in console mode
- First WCF App (Host in Console Application)
- Show Console Window in Windows Application
- Create Console for Logging in Win32 Application
- Distributed Application in .Net
- Using the Web Services and COM+ Event System in the .Net Application.
- C语言数组负索引
- flex工程网络部署注意问题总结
- C语言运算符优先级 详细列表
- PHP中for循环语句的几种“变态”用法
- linux小记4 查看帮助
- Using Spring.net in console application
- Houdini一键修改Alembic相机分辨率。
- 类似于qq联系人的tablview能够展开和收缩
- position(relative和absolute)
- C++著名类库
- Solaris10 安装curl
- androidの编辑联系人,姓名颠倒bug
- 网线线序接法
- linux 批量 压缩 打包