Overridable injections for Microsoft.Extensions.DependencyInjection.
var provider = new ServiceCollection()
.AddTransient<IExampleService1, ExampleService1A>()
// REQUIRED: Adds override capability for IExampleService1
.AddOverridability(typeof(IExampleService1))
.BuildServiceProvider();
// SCOPE
using (var scope = provider.CreateScope())
{
// Override the service implementation for this scope
scope.Override<IExampleService1, ExampleService1B>();
// Testing the override
var serviceInstance = scope.ServiceProvider.GetRequiredService<IExampleService1>();
Console.WriteLine($"IExampleService1 overridden: {serviceInstance is ExampleService1B}");
}