In some IoC containers it is possible to have arguments in the constructor that can't be fulfilled by the container. Is this possible with the Microsoft.Extensions.DependencyInjection libraries and IServiceProvider? If not, what is a clean solution for this sort of problem?
For example:
class InContainer
{
public InContainer(NotInContainer dependency) { ... }
}
class Consumer
{
public Consumer(IServiceProvider serviceProvider)
{
NotInContainer currentDependency = ... // from some other source
// passing the anonymous object here is not supported,
// but I would like to
InContainer = serviceProvider.GetService<InContainer>(
new { dependency = currentDependency }
);
}
}