ArrowDb.DependencyInjection 2.0.0

dotnet add package ArrowDb.DependencyInjection --version 2.0.0
                    
NuGet\Install-Package ArrowDb.DependencyInjection -Version 2.0.0
                    
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="ArrowDb.DependencyInjection" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ArrowDb.DependencyInjection" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ArrowDb.DependencyInjection" />
                    
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 ArrowDb.DependencyInjection --version 2.0.0
                    
#r "nuget: ArrowDb.DependencyInjection, 2.0.0"
                    
#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 ArrowDb.DependencyInjection@2.0.0
                    
#: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=ArrowDb.DependencyInjection&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ArrowDb.DependencyInjection&version=2.0.0
                    
Install as a Cake Tool

ArrowDb.DependencyInjection

Dependency injection support for ArrowDb.

This package provides IArrowDbProvider, the public generic ArrowDbProvider<TSerializer>, and an optional hosted-service primer for eager startup initialization.

Install

dotnet add package ArrowDb.DependencyInjection

Register

builder.Services.AddSingleton(new FileSerializer(path, ArrowDbJsonContext.Default.ConcurrentDictionaryStringByteArray));
builder.Services.AddSingleton<IArrowDbProvider, ArrowDbProvider<FileSerializer>>();

For AES-backed storage:

builder.Services.AddSingleton(_ => Aes.Create());
builder.Services.AddSingleton(serviceProvider =>
    new AesFileSerializer(
        path,
        serviceProvider.GetRequiredService<Aes>(),
        ArrowDbJsonContext.Default.ConcurrentDictionaryStringByteArray));
builder.Services.AddSingleton<IArrowDbProvider, ArrowDbProvider<AesFileSerializer>>();

If you want eager host-startup initialization for a singleton provider, also add:

builder.Services.AddArrowDbInitialization();

Consume

public sealed class MyService {
    private readonly IArrowDbProvider _provider;

    public MyService(IArrowDbProvider provider) {
        _provider = provider;
    }

    public async Task<int> CountAsync() {
        ArrowDb db = await _provider.GetAsync();
        return db.Count;
    }
}

ArrowDbProvider<TSerializer> does not dispose the serializer by default. That fits the common DI case where the serializer is registered separately and the container owns it.

If you want the provider to own the serializer lifetime instead, register it with a factory and pass disposeSerializer: true:

builder.Services.AddSingleton<IArrowDbProvider>(_ =>
    new ArrowDbProvider<FileSerializer>(
        new FileSerializer(path, ArrowDbJsonContext.Default.ConcurrentDictionaryStringByteArray),
        disposeSerializer: true));

If you register the provider as a singleton and add AddArrowDbInitialization(), the host will prime it during startup.

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
2.0.0 37 4/14/2026