IOC & DI

IOC的优点

when using DI / IoC Container, we may replace SomeService with SomeTestService on registration side, without needing to change anything on the consuming
side.

使用容器中的对象的方式:Resolve(显示用Resolvecoin从容器中拿) 或 DI(构造函数注入).

注册单例

container.Register<IA,A>(Reuse.Singleton);
posted @ 2024-03-23 21:17  数字游民  阅读(2)  评论(0编辑  收藏  举报