ZCrew.Extensions.DependencyInjection 3.0.1

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

ZCrew.Extensions.DependencyInjection

Decorator support for Microsoft.Extensions.DependencyInjection. Wrap a service that's already registered with another implementation, using an API that looks like the one you already use.

What you get

  • Decorators registered by type, or built by a factory
  • A lifetime of your choosing (AddSingletonDecorator, AddScopedDecorator, AddTransientDecorator) or the one the wrapped service already has (AddDecorator)
  • Keyed services (AddKeyedDecorator, AddKeyedSingletonDecorator, and so on)
  • Mismatched lifetimes caught at registration, like a singleton decorator around a transient service
  • As many decorators on one service as you want. Call AddDecorator again

Installation

dotnet add package ZCrew.Extensions.DependencyInjection

or in your .csproj:

<ItemGroup>
  <PackageReference Include="ZCrew.Extensions.DependencyInjection" Version="3.0.0" />
</ItemGroup>

This one is plain library code. There's no analyzer or source generator involved, so there's nothing else to configure.

Quick start

Given a service and a decorator:

public interface IGreeter
{
    string Greet(string name);
}

public class Greeter : IGreeter
{
    public string Greet(string name) => $"Hello, {name}!";
}

public class LoggingGreeter(IGreeter inner, ILogger<LoggingGreeter> logger) : IGreeter
{
    public string Greet(string name)
    {
        logger.LogInformation("Greeting {Name}", name);
        return inner.Greet(name);
    }
}

Register the decorator:

services.AddScoped<IGreeter, Greeter>();

// Inherit the lifetime of the service being wrapped (scoped here)
services.AddDecorator<IGreeter, LoggingGreeter>();

// Or set one explicitly
services.AddSingletonDecorator<IGreeter, LoggingGreeter>();

Use a factory when you want to build it yourself:

services.AddDecorator<IGreeter>((provider, inner) =>
    new LoggingGreeter(inner, provider.GetRequiredService<ILogger<LoggingGreeter>>()));

Keyed services

services.AddKeyedScoped<IGreeter, Greeter>("friendly");
services.AddKeyedDecorator<IGreeter, LoggingGreeter>("friendly");

License

MIT. See LICENSE.md.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 (1)

Showing the top 1 NuGet packages that depend on ZCrew.Extensions.DependencyInjection:

Package Downloads
ZCrew.Extensions.DependencyInjection.Registration

Adds assembly scanning to Microsoft.Extensions.DependencyInjection similar to Castle.Windsor

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.1 128 8/21/2026
3.0.0 139 8/3/2026
3.0.0-preview.2 71 7/19/2026
3.0.0-preview.1 72 7/15/2026
2.0.0 141 5/23/2026
1.1.0 138 3/25/2026
1.0.1 136 3/19/2026
1.0.0 138 3/19/2026
1.0.0-preview.1 81 2/22/2026