简单的 IoC 容器 BarbarianIOC

码农软件 · 软件分类 · 面向方面AOP/IoC · 2019-09-29 10:59:55

软件介绍

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();

本文地址:https://www.codercto.com/soft/d/15648.html

编程人生

编程人生

Peter Seibel / 图灵俱乐部 / 人民邮电出版社 / 2011-1-1 / 79.00元

界顶尖的程序员是怎么走上编程道路的? 他们的编程工作创造和改变了人类历史,在这一过程中都有哪些经验和教训? 他们对计算机软件行业的过去、现在和未来有什么独到的看法和见解? 他们对培养、发现、选拔、面试优秀的程序员有什么建议? 放下手头的工作,听听这些软件先驱们的故事和建议,眼界可以更开阔,思路可以更清晰,方向可以更明确,人生可以更精彩。 作者Peter Seibel采......一起来看看 《编程人生》 这本书的介绍吧!

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具