| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
12年前发布

简单的 IoC 容器:BarbarianIOC

BarbarianIOC 是一个简单的 .NET 实现的 IoC 容器,示例代码:

Container = new Container();  int someMockAge = 23; // this could come from anywhere (App.Config / database etc etc)    //Register ALL components  container.RegisterComponents(          //where you can use concrete type          new Component().For<Foo>().WithInstanceMode(InstanceMode.Transient),          //or you can use an interface and it's implementation          new Component().For<IBaz>().ImplementedBy<Baz>().WithInstanceMode(InstanceMode.Transient),          //and you can also declare singleton instance mode if you like          new Component().For<SomeIBazDependantClass>().WithInstanceMode(InstanceMode.Singleton),          //and even supply some non IOC provided constructor params by way of an anonymous object          new Component().For<SomeFooDependantClass>()              .DependsOn(new                   {                       age=someMockAge                  })              .WithInstanceMode(InstanceMode.Transient)      );                //allow the container to wire stuff up (essentially create Expression.New for all   //components to allow Container to compile and create some quicker lookup delegates)  container.WireUp();

项目主页:http://www.open-open.com/lib/view/home/1361839694927

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1361839694927.html
面向方面AOP/IoC BarbarianIOC