Question

Is is possible to get the container instance back from ServiceLocation? I only see the ability to resolve instances of types, not register them.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top