作者:不完整的记忆721_560 | 来源:互联网 | 2023-05-23 10:42
在Castle Windsor场景中,我想检查我的容器是否已注册某个服务,并且基本上做了
if (container.HasComponentFor()) {
// resolve service with container.Resolve()
// then do cool stuff
}
但当然container.HasComponentFor()
不存在.有同等的吗?
1> 小智..:
您可以检查MicroKernel是否已注册组件:
if (container.Kernel.HasComponent(typeof(IMyService)))
// resolve service with container.Resolve()
// then do cool stuff
}