容器构建完成后添加服务 [英] Adding services after container has been built
本文介绍了容器构建完成后添加服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在运行时注册服务,这意味着在构建了 ContainerBuilder
并且创建了 Container
(以及 ContainerBuilder
代码>处置)?
Is it possible to register a service at run-time, meaning after the ContainerBuilder
has been built and the Container
has been created (and ContainerBuilder
disposed of)?
推荐答案
是的,你可以,使用 ContainerBuilder
上的 Update
方法:
Yes you can, using the Update
method on ContainerBuilder
:
var newBuilder = new ContainerBuilder();
newBuilder.Register...;
newBuilder.Update(existingContainer);
这篇关于容器构建完成后添加服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文