标签:des style blog http color io os ar for
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace SpringNetStudy1024 8 { 9 class Mutudu:IMutudu 10 { 11 public void Show() 12 { 13 Console.WriteLine( "小杜成功的写了一个Spring.Net的案例" ); 14 } 15 } 16 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace SpringNetStudy1024 8 { 9 interface IMutudu 10 { 11 void Show(); 12 } 13 }
1 <?xml version="1.0" encoding =" utf-8" ?> 2 <configuration> 3 < configSections> 4 < sectionGroup name =" spring" > 5 < section name =" context" type="Spring.Context.Support.ContextHandler, Spring.Core" /> 6 < section name =" objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" /> 7 </ sectionGroup> 8 </ configSections> 9 < spring> 10 < context> 11 < resource uri =" config://spring/objects"/> 12 </ context> 13 < objects xmlns =" http://www.springframework.net"> 14 < description>An example that demonstrates simple IoC features.</description> 15 </ objects> 16 </ spring> 17 </configuration>
1 <? xml version =" 1.0" encoding =" utf-8" ?> 2 < configuration> 3 < configSections > 4 < sectionGroup name =" spring" > 5 < section name =" context" type =" Spring.Context.Support.ContextHandler, Spring.Core" /> 6 < section name =" objects" type =" Spring.Context.Support.DefaultSectionHandler, Spring.Core" /> 7 </ sectionGroup > 8 </ configSections > 9 < spring > 10 < context > 11 < resource uri =" config://spring/objects "/> 12 </ context > 13 < objects xmlns =" http://www.springframework.net "> 14 < description >An example that demonstrates simple IoC features.</ description> 15 <!-- 下面就是将类交给窗口管理的配置代码,仅此一行。 --> 16 < object name =" Mutudu" type =" SpringNetStudy1024.Mutudu, SpringNetStudy1024" > </ object> 17 </ objects > 18 </ spring > 19 </ configuration> 20
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 using Spring.Context; 11 using Spring.Context.Support; 12 13 namespace SpringNetStudy1024 14 { 15 public partial class Form1 : Form 16 { 17 public Form1() 18 { 19 InitializeComponent(); 20 } 21 22 private void PowerOfIoC_Click( object sender, EventArgs e) 23 { 24 //这里返回的或者说得到的就是根据我们在object节点的内容配置好的容器的对象。 25 IApplicationContext ctx = ContextRegistry .GetContext(); 26 //然后就可以通过得到的对象,得到实例了。 27 IMutudu mutudu = ( IMutudu)ctx.GetObject( "Mutudu"); 28 //调用一下方法。 29 mutudu.Show(); 30 } 31 } 32 }
这个好像、也许、或许、大概、应该、Maybe真的可以算是传说中的Spring.Net了吧
标签:des style blog http color io os ar for
原文地址:http://www.cnblogs.com/anmutu/p/4049172.html