开发者

How do I get the container instance back from ServiceLocation?

Is is possible to get the container instance back from Servi开发者_如何学PythonceLocation? I only see the ability to resolve instances of types, not register them.


You can't. CommonServiceLocator only abstracts resolution, not registration. One of the reasons is that registration is wildly different for each particular container.

As Krzysztof commented, try to avoid service locator as much as possible. It might be necessary for some special cases to resolve something, but never to register.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜