Asya.DependencyInjection
1.0.0
dotnet add package Asya.DependencyInjection --version 1.0.0
NuGet\Install-Package Asya.DependencyInjection -Version 1.0.0
<PackageReference Include="Asya.DependencyInjection" Version="1.0.0" />
paket add Asya.DependencyInjection --version 1.0.0
#r "nuget: Asya.DependencyInjection, 1.0.0"
// Install Asya.DependencyInjection as a Cake Addin #addin nuget:?package=Asya.DependencyInjection&version=1.0.0 // Install Asya.DependencyInjection as a Cake Tool #tool nuget:?package=Asya.DependencyInjection&version=1.0.0
Asya Dependency Injection a lightweight dependency injection assembly scanner
you can simply inject your dependencies with a smart attribute decoration and let the package take of your DI registration for the 4 common injection methods (Transient
, Singleton
, Scoped
, Hosted
) as following
let's talk about the injection after
I have created a simple interface with a single method as IExample.cs
and implementation as ExampleManager.cs
as following
using Asya.DependencyInjection.Attributes;
namespace Asya.DependencyInjection { [Scoped] public interface IExample { void Transaction(); } }
and the implementation
using System;
namespace Asya.DependencyInjection
{
public class ExampleManager: IExample
{
public void Transaction()
{
throw new NotImplementedException();
}
}
}
all you want is to mention the attribute as decoration on top of your interface or class you can use one of the following
[Scoped]
, [Singleton]
, [Transient]
, [Hosted]
then in your startup class you can simple inject this with single method as
service.ScanDependencies();
which will scan all services around your internal assembly and register each depended on the decoration attribute
OR
you can analysis you code with register each using the AddServiceOfType<TAttrubite>()
; as following
AddServiceOfType<Singleton>();
AddServiceOfType<Scoped>();
AddServiceOfType<Transient>();
AddServiceOfType<Hosted>();
which also will scan your assembly to get dependencies
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net5.0
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 |
---|
the initial release