Phymnary.SugarPot.DependencyInjection
1.0.2
dotnet add package Phymnary.SugarPot.DependencyInjection --version 1.0.2
NuGet\Install-Package Phymnary.SugarPot.DependencyInjection -Version 1.0.2
<PackageReference Include="Phymnary.SugarPot.DependencyInjection" Version="1.0.2" />
<PackageVersion Include="Phymnary.SugarPot.DependencyInjection" Version="1.0.2" />
<PackageReference Include="Phymnary.SugarPot.DependencyInjection" />
paket add Phymnary.SugarPot.DependencyInjection --version 1.0.2
#r "nuget: Phymnary.SugarPot.DependencyInjection, 1.0.2"
#:package Phymnary.SugarPot.DependencyInjection@1.0.2
#addin nuget:?package=Phymnary.SugarPot.DependencyInjection&version=1.0.2
#tool nuget:?package=Phymnary.SugarPot.DependencyInjection&version=1.0.2
Phymnary.SugarPot.DependencyInjection
Lightweight primitives for convention-based dependency registration.
This project provides simple contracts and attributes to standardize how services are discovered and added to the .NET IServiceCollection.
Features
IAutoRegisterinterface for explicit dependency registration[Auto]marker attribute for discoverable classes[Service(Lifetime)]attribute to declare service lifetimeLifetimeenum (Singleton,Scoped,Transient)- Optional self-registration with
ServiceAttribute.IsSelf
Installation
Install-Package Phymnary.SugarPot.DependencyInjection
API Overview
IAutoRegister
Implement this interface when a module/class should register dependencies manually:
using Microsoft.Extensions.DependencyInjection;
using Phymnary.SugarPot.DependencyInjection;
public sealed class UserAutoRegister : IAutoRegister
{
public void AddDependencies(IServiceCollection services)
{
services.AddScoped<IUserRepository, UserRepository>();
}
}
[Auto]
Use this marker attribute to indicate a class is eligible for automatic discovery/registration by consumers:
using Phymnary.SugarPot.DependencyInjection;
[Auto]
public sealed class BackgroundJobRunner
{
}
[Service]
Use this attribute to declare the intended lifetime:
using Phymnary.SugarPot.DependencyInjection;
[Service(Lifetime.Scoped)]
public sealed class UserService : IUserService
{
}
Register as self (concrete type) when needed:
[Service(Lifetime.Singleton, IsSelf = true)]
public sealed class CacheWarmupService
{
}
Notes
- This project intentionally stays minimal and framework-agnostic.
- Actual assembly scanning/registration behavior is implemented by consuming projects.
Target Frameworks
- .NET Standard 2.1
| Product | Versions 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. |
-
net10.0
-
net8.0
-
net9.0
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Phymnary.SugarPot.DependencyInjection:
| Package | Downloads |
|---|---|
|
Phymnary.SugarPot.Module
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.