BitzArt.TransientServiceProvider 1.4.1

Prefix Reserved
dotnet add package BitzArt.TransientServiceProvider --version 1.4.1
                    
NuGet\Install-Package BitzArt.TransientServiceProvider -Version 1.4.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BitzArt.TransientServiceProvider" Version="1.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BitzArt.TransientServiceProvider" Version="1.4.1" />
                    
Directory.Packages.props
<PackageReference Include="BitzArt.TransientServiceProvider" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BitzArt.TransientServiceProvider --version 1.4.1
                    
#r "nuget: BitzArt.TransientServiceProvider, 1.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BitzArt.TransientServiceProvider@1.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BitzArt.TransientServiceProvider&version=1.4.1
                    
Install as a Cake Addin
#tool nuget:?package=BitzArt.TransientServiceProvider&version=1.4.1
                    
Install as a Cake Tool

NuGet version NuGet downloads

Overview

BitzArt.DependencyInjection.TransientServiceProvider is a NuGet package that allows the creation of transient service providers - each with its own set of services. Transient service providers are isolated from each other and from the default service provider.

How it Works

1. Install

You can install the package via NuGet using the following command:

dotnet add package BitzArt.DependencyInjection.TransientServiceProvider

2. Configure

Add transient service provider factory to your service collection:

services.AddTransientServiceProvider(serviceCollection =>
    {
        // Add services to the serviceCollection here.
    });

3. Resolve

Once the configuration is complete, you can resolve ITransientServiceProvider

  • either directly from the root service provider
var transient = serviceProvider.GetRequiredService<ITransientServiceProvider>();
  • or by injecting it into one of your classes
public class MyService(ITransientServiceProvider transientServiceProvider)
{
    // ...
}

4. Use

Use the resolved ITransientServiceProvider similarly to how you would use a normal IServiceProvider

var myTransientService = transientServiceProvider.GetService<MyService>();
4.1. Use FallbackToGlobal flag

You can use the FallbackToGlobal flag in the options configuration and inject dependencies directly. If this FallbackToGlobal flag is enabled in the configuration, the system will first attempt to obtain the dependency from the ITransientServiceProvider container. This is useful when you need to override or isolate certain services in a specific context, for example, for testing or performing specific tasks. If the required dependency is not found in ITransientServiceProvider and the FallbackToGlobal flag is enabled, the search will continue in the global default container.

You can find a configuration example in the Startup file of the BitzArt.TransientServiceProvider.XUnitDependencyInjectionTests project.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.1 501 11/24/2025
1.4.0 228 11/24/2025
1.3.0 663 9/14/2025