WithFactory configuration and open generics #138
Replies: 3 comments 2 replies
-
Hi @michaelplavnik, thanks for reaching out! Just to verify that I understand your case correctly, do you need an option that sets a |
Beta Was this translation helpful? Give feedback.
-
Thats an interesting approach because it can make it unneccessary to move all the registrations from Microsoft's ServiceCollection into Stashbox. Simply ask Microsoft for unknown service instances. |
Beta Was this translation helpful? Give feedback.
-
If I understand the case correctly, only singletons should come from the parent new StashboxContainer(c => c.WithUnknownTypeResolution(opts =>
{
opts.WithFactory(() => serviceProvider.GetRequiredService(opts.ServiceType));
})); @michaelplavnik What do you think? It's not possible yet, but I'm already working on allowing this behavior. |
Beta Was this translation helpful? Give feedback.
-
I was trying to use WithFactory configuration to implement delegation resolution of some singleton services to external DI system (Microsoft). It all works well for closed types, but I do not see how to make it work for open generics. Neither IDependencyResolver, or IRequestContext carry information about dependency type.
May be it is a possible to provide configuration method WithServiceProvider(serviceProvider) ?
Implementing custom resolver along the following line might be excessive in this case.
Beta Was this translation helpful? Give feedback.
All reactions