You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.
We're going to add this interface to allow container implementors to directly call into their intrinsics without checking for existence and returning null. It also lets GetRequiredService fail with container specific diagnostics instead of our own. This interface would be optional and we would light it up here:
Thank you. This will make it easier for StructureMap users to correct common registration problems that could be hidden behind the previously default TryGetInstance<T> mechanics.
Consider the case where a users is using some kind of conventional scanning to register types, and it finds two different concrete types of IService and registers each. In StructureMap, we will not choose either the first or last registration as the "default", in the case of multiples you have to explicitly choose one or the other. In the case of asking for IService through IContainer.GetInstance<IService>(), StructureMap will tell you it has no default because more than one is registered, with a complete listing of each. That's a common problem in SM usage and one that would be much easier to solve for users w/ this new GetRequiredService() feature.
davidfowl
changed the title
Add interface to allow container implementors to optimize service lookup
Add interface to allow container implementors to expose a more native service lookup for required services
Mar 9, 2016
We're going to add this interface to allow container implementors to directly call into their intrinsics without checking for existence and returning null. It also lets GetRequiredService fail with container specific diagnostics instead of our own. This interface would be optional and we would light it up here:
https://github.com/aspnet/DependencyInjection/blob/dev/src/Microsoft.Extensions.DependencyInjection.Abstractions/ServiceProviderExtensions.cs#L38
If the interface exists, we would call it directly, otherwise we'll use the existing behavior.
See the original discussion here #238.
Name suggestions are welcome.
/cc @jeremydmiller
The text was updated successfully, but these errors were encountered: