本文介绍了构建容器后添加服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在运行时注册服务,这意味着在构建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);

这篇关于构建容器后添加服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 17:33