Hasim.Injectify
0.1.4
dotnet add package Hasim.Injectify --version 0.1.4
NuGet\Install-Package Hasim.Injectify -Version 0.1.4
<PackageReference Include="Hasim.Injectify" Version="0.1.4" />
<PackageVersion Include="Hasim.Injectify" Version="0.1.4" />
<PackageReference Include="Hasim.Injectify" />
paket add Hasim.Injectify --version 0.1.4
#r "nuget: Hasim.Injectify, 0.1.4"
#:package Hasim.Injectify@0.1.4
#addin nuget:?package=Hasim.Injectify&version=0.1.4
#tool nuget:?package=Hasim.Injectify&version=0.1.4
Injectify
A modular dependency injection system for ASP.NET Core applications. Automatically discovers modules across all projects in a solution — no manual registration needed.
Concept
Each project in your solution (Application, Core, EF Core, UI, etc.) defines its own module that registers its own dependencies. The host project (UI) discovers and initializes all modules automatically with just two calls:
// Program.cs — only 2 lines needed
var builder = WebApplication.CreateBuilder(args);
builder.InjectifyApplication();
// ...
var app = builder.Build();
app.InjectifyInitializer();
app.Run();
Features
| Feature | Description | Status |
|---|---|---|
| Module System | Autonomous modules with DI registration and pipeline configuration | ✅ |
| Auto-Discovery | Recursive assembly scanning to discover all IModule implementations | ✅ |
| Module Metadata | [ModuleInfo], [ModuleOrder], [DependsOn] attributes |
✅ |
| Dependency Graph | DAG validation with topological sort and cycle detection | ✅ |
| Lifecycle Hooks | OnInit, OnStart, OnStop via IModuleLifecycle |
✅ |
| Auto DI Registration | Marker interfaces (IAddSingleton, IAddScoped, IAddTransient) for automatic service registration |
✅ |
| Unified DI API | Single AddInjectifyServices() call registers all marker-implementing classes |
✅ |
Installation
dotnet add package Injectify
Quick Start
1. Create a module in each project (optional for DI-only services)
using Injectify.Modules;
[ModuleInfo("My Module", "1.0.0", "Description of the module")]
[ModuleOrder(10)]
public class MyModule : BaseInjectifyModule
{
public override void ConfigureService(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped<IMyService, MyService>();
}
public override void ConfigureApplication(WebApplication app)
{
app.Logger.LogInformation("MyModule initialized");
app.UseMiddleware<MyMiddleware>();
}
}
2. In the UI project — 2 lines (discovers modules + auto-registers services)
var builder = WebApplication.CreateBuilder(args);
builder.InjectifyApplication(); // Scans all assemblies, discovers all IModule + auto-registers IAddSingleton/IAddScoped/IAddTransient
var app = builder.Build();
app.InjectifyInitializer(); // Calls ConfigureApplication on each module
app.Run();
3. Auto-register services with marker interfaces (new!)
Instead of manually registering services in ConfigureService, implement the appropriate marker interface on your service implementation:
using Injectify.Abstractions;
// Automatically registered as Scoped
public interface IUserService : IAddScoped { }
public class UserService : IUserService { }
// Automatically registered as Singleton
public interface ICacheService : IAddSingleton { }
public class CacheService : ICacheService { }
// Automatically registered as Transient
public interface IEmailService : IAddTransient { }
public class EmailService : IEmailService { }
No manual services.AddScoped<>() calls needed — builder.InjectifyApplication() handles it automatically.
3. Module lifecycle
public class MyModule : BaseInjectifyModule
{
public override void OnInit(IServiceCollection services) { /* before registration */ }
public override void OnStart(WebApplication app) { /* after build, before run */ }
public override void OnStop() { /* on shutdown */ }
}
4. Module dependencies
[DependsOn(typeof(CoreModule))]
[DependsOn(typeof(EFCoreModule))]
public class UIModule : BaseInjectifyModule { }
Packages
| Package | Description |
|---|---|
Injectify |
Module system with DI registration, pipeline config, and module lifecycle |
Project structure
Injectify/
├── Abstractions/ # Marker interfaces: IAddSingleton, IAddScoped, IAddTransient
├── Attributes/ # [DependsOn], [ModuleInfo], [ModuleOrder]
├── Exceptions/ # InjectifyException, DependencyCycleException
├── Extensions/ # Fluent DI extensions (InjectifyApplication, InjectifyInitializer, DependencyInjectionExtensions)
├── Modules/ # IModule, IModuleLifecycle, BaseInjectifyModule
├── Setup/ # IModuleLoader, ModuleLoader (assembly scanning, topological sort)
└── Injectify.Tests/ # Unit tests (xUnit)
Documentation
- README.fr.md — Documentation en français
- AUDIT.md — Audit findings & technical debt
License
MIT
| 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 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. |
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Hasim.Injectify:
| Package | Downloads |
|---|---|
|
Hasim.Auditify
A lightweight, pluggable audit-trail library for EF Core 8+. Automatically captures entity changes (Added/Modified/Deleted), supports sensitive data masking, soft-delete patterns, and timestamp tracking. |
|
|
Hasim.EntityFrameworkCore
A customizable ASP.NET Core Identity entities library providing reusable base identity models and common abstractions for modern .NET applications. |
|
|
Hasim.Infrastructure
Todo Description. |
GitHub repositories
This package is not used by any popular GitHub repositories.