开发者

How do I get the container instance back from ServiceLocation?

开发者 https://www.devze.com 2023-01-16 13:59 出处:网络
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 onl

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

精彩评论

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

关注公众号