Open LeonxPRO opened 1 year ago
Hello @LeonxPRO! 👋🏻
The issue with providing a factory like that is that it needs to work for all subtypes of TService
, so you it would also have to know the specific type that it's trying to register in the callback.
I'd love to know a bit more about what you're trying to do. Do you have a concrete example?
Sample is pretty straighforward, just have a bunch of classes that have the same interface for wich you want to have a property filled during creation.
.WithSingletonLifetime(Func<IServiceProvider, TService> implementationFactory)) would be awesome :)
Any progress on this one? Basically it would be nice to get a callback for instance creation; (IServiceProvider, Type concreteType)
Hello! First, thanks for a Scrutor) Is it any way for register services with ImplementationFactory, like in native
IServiceCollection
method ?AddSingleton<TService>(Func<IServiceProvider, TService> implementationFactory)
I imagine that like:instead
WithSingletonLifetime()