Skip to content

Repository files navigation

OverridableDependencyInjection NuGet version

Overridable injections for Microsoft.Extensions.DependencyInjection.

Example

varprovider=newServiceCollection().AddTransient<IExampleService1,ExampleService1A>()// REQUIRED: Adds override capability for IExampleService1.AddOverridability(typeof(IExampleService1)).BuildServiceProvider();// SCOPEusing(varscope=provider.CreateScope()){// Override the service implementation for this scopescope.Override<IExampleService1,ExampleService1B>();// Testing the overridevarserviceInstance=scope.ServiceProvider.GetRequiredService<IExampleService1>();Console.WriteLine($"IExampleService1 overridden: {serviceInstanceisExampleService1B}");}

Program.cs

About

Overridable injections for Microsoft.Extensions.DependencyInjection

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages