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  ValueLee  阅读(9)  评论(0)    收藏  举报