vl
Условно:
interface IFactory {
object Create(string param)
}
class Factory : IFactory {
private readonly IServiceScopeFactory _serviceScope
ctor(_serviceScope)
object Create(string param) {
using var scope = _serviceScope.CreateScope();
return scope.ServiceProvider.GetServices<IBar>()
.First(service => service.Param == param);
}
}
inetrface IFoo {}
class Foo : IFoo {
private readonly IFactory _factory
ctor(_factory)
}
Как зарегистрировать IFactory, IFoo, IBar
?