优先顺序从上至下
AddTransient<>();
AddScoped<>();
AddSingleton<>();
使用注意!
用AddTransient或AddSingleton
AddScoped 不是给注入构造器用的
使用建议
infrustruction(基础设施)如eventBus,windowManager,Apiserver建议用Singleton
无状态的service才考虑AddTransient
优先顺序从上至下
AddTransient<>();
AddScoped<>();
AddSingleton<>();
使用注意!
用AddTransient或AddSingleton
AddScoped 不是给注入构造器用的
使用建议
infrustruction(基础设施)如eventBus,windowManager,Apiserver建议用Singleton
无状态的service才考虑AddTransient
本文标题:Microsoft DI中的三个注册方法
本文链接:https://www.haomeiwen.com/subject/exkrhltx.html
网友评论