Skip to content
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

public GetAvailableServices #511

Open
alandraper opened this issue Sep 27, 2019 · 0 comments
Open

public GetAvailableServices #511

alandraper opened this issue Sep 27, 2019 · 0 comments

Comments

@alandraper
Copy link

I'm trying to implement a Newtonsoft.DefaultContractResolver similar to this
https://www.newtonsoft.com/json/help/html/DeserializeWithDependencyInjection.htm

To resolve a type , I need to know if that type is registered with the container, and if so, what the ImplementingType is (Also I'd like to be able to know what the lifetime is as well).

But the method ServiceContainer.GetAvailableServices is private, and I can't figure out a way to get them. I see that GetAvailableServices has side effects -- it possibly Adds to the available services if not found.

Maybe a public method added to the interface GetRegisteredServices(Type serviceType) implemented like this?

public IEnumerable<KeyValuePair<string, ServiceRegistration>> GetRegisteredServices(Type serviceType) {
	return availableServices.ContainsKey(serviceType) ? availableServices[serviceType] : null;
}

Happy to contribute a pull request if you think it's worthwhile, or consider why it's a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant