-
-
Notifications
You must be signed in to change notification settings - Fork 120
Added GetRegisteredServices #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Added GetRegisteredServices #513
Conversation
|
Hi @alandraper I am just wondering why |
|
It would, but then I have to look through all registrations every time, or build up a dictionary for lookups, which would duplicate the dictionary you already have. |
|
I'm just trying to understand this example What is actually going on here. Do you have a simpler example of what you are trying to do? Some of the types are not even in the example 😀 |
|
Sure. I'm trying to create a Newtonsoft.Json.Serialization.IContractResolver which uses LightInject to create objects. This way, when I call JsonConvert.DeserializeObject(json), it will use the LightInject container for object resolution. Here's the implementation I'm working with now, which seems to be working. And here's how it's used: |
|
This is also useful for implementing an easy IsRegistered(Type) method for a given service type. Any chance of this being accepted? Or anything I can do to make it more palatable? It's hard to work from my own codebase when Umbraco references the nuget package, and running two dependency injectors on the same site seems like a recipe for trouble. |
|
Are there any plans to move this foward? I know its a nice to have, but for the reasons mentioned, its better to use the internal dictionary instead of creating a new one. For example in my use case I wanted to retrieve the implementing type from the handler (after being decorated it returns an instance of the decorator). And maybe this could be available on IServiceRegistry instead of IServiceFactory? Or both? |
Added GetRegisteredServices methods to expose the list of ServiceRegistrations available for a given type. This makes it possible to create a JsonContractResolver which resolves to the LightInject supplied type. Also added to mock.