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
MikeAlhayek
changed the title
Add a way to resolve IDictionary<,> from keyed service
Add a way to get IReadOnlyDictionary<,> of keyed services
Dec 3, 2023
I would rather add some options metadata together with the registration of the keyed services (and that works also non-keyed services).
Example:
services.AddKeyedTransient<IService, Service1>("a");
services.AddKeyedTransient<IService, Service2>("b");
options.AvailableIServices.Add("a", "This is the best IService", "logo.png");
options.AvailableIServices.Add("b", "This is the second best IService", "logo2.png");
And usually you would have an extension method to add both the service and the registration in the options:
services.AddAwesomeServices<Service1>("a"); // where T : IService
services.AddAwesomeServices<Service2>("b");
Then you can list all available services, and their description. Then store "a" or "b" in the database for the selected one. And use the key to resolve the service.
With non-keyed services you can also store the type directly in the metadata.
Add a way to provide
IReadOnlyDictionary<,>
of keyed serviceThe text was updated successfully, but these errors were encountered: