SnappyLib.Gen.AutoInject 3.0.6

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

Generator Documentation

The purpose of this generator is to automatically register types into the Dependency Injection (DI) container based on the attributes applied to the class. These attributes determine the lifetime of the registered service and are as follows:

Supported Lifetime Attributes
  • [HostedService] Registers the class as a hosted background service that implements the IHostedService interface.

  • [Transient]
    Registers the class as a transient service, meaning a new instance is created every time it's requested.

  • [Scoped]
    Registers the class as a scoped service, meaning a new instance is created for each scope (e.g., per HTTP request in a web application).

  • [Singleton]
    Registers the class as a singleton service, meaning only one instance exists for the lifetime of the application.


Behavior

When a type is annotated with one of the supported attributes, the generator will:

  1. Register the type itself with the DI container using the specified lifetime.
  2. Register all interfaces the type implements with the DI container, resolving to the annotated type and using the same specified lifetime.

Usage

To use this, annotate your service class with one of the lifetime attributes ([HostedService], [Transient], [Scoped], or [Singleton]) and implement any required interfaces. The generator will handle the registration automatically.

Example
[Transient]
public class MyService : IMyService
{
    // Implementation...
}

In this example:

  • The generator will register MyService itself as a transient service.
  • The generator will also register the IMyService interface as a transient service and resolve it to MyService.
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

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
3.0.6 204 3/13/2025