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.