Automation.DependencyInjection 1.0.0

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

Automation.DependencyInjection is an attribute-based dependency injection framework for ASP.NET Core. It simplifies the process of registering services in the DI container by using custom attributes to define service lifetimes (Singleton, Scoped, or Transient). The framework automatically scans assemblies and registers services, reducing manual service registration.

Installation

You can install this library by cloning the repository or via NuGet:

Install-Package Automation.DependencyInjection

Key Features

  • Attribute-based Service Registration: Use the [Injectable] attribute to specify the service's lifetime (Singleton, Scoped, or Transient), simplifying dependency injection.

  • Automatic Discovery and Registration: The framework scans assemblies for classes marked with the [Injectable] attribute and automatically registers them with the DI container.

  • Flexible Service Registration:

    • Self-registration: Automatically registers a class if it doesn't implement any interfaces or abstract base classes.
    • Interface and Abstract Class Support: Registers all implemented interfaces and abstract base classes, ensuring that services are injected based on both concrete and abstract types.
  • Lifetime Support: The InjectableAttribute supports all service lifetimes (Singleton, Scoped, Transient), allowing for flexible service management.

Usage

Step 1: Register Services Automatically

In your Program.cs or service collection, call the AddAutomation() method to automatically scan and register all services marked with the [Injectable] attribute.

public void ConfigureServices(IServiceCollection services)
{
    services.AddAutomation(Assembly.GetExecutingAssembly());
}

Step 2: Add [Injectable] Attribute

Add the [Injectable] attribute to any class that should be injected into the DI container. Specify the lifetime (Singleton, Scoped, or Transient) when using the attribute.

[Injectable(ServiceLifetime.Singleton)]
public class MyService : IMyService
{
    // Implementation
}

Step 3: Simplify Your DI Setup

By using attribute-based dependency injection, this framework simplifies service registration in large projects, reducing boilerplate code and minimizing manual service registrations.

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 was computed.  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 was computed.  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.0.0 213 9/8/2024