{"id":37043703,"url":"https://github.com/nurlanvalizada/nlbinjecto","last_synced_at":"2026-01-14T05:01:33.024Z","repository":{"id":258575554,"uuid":"874038699","full_name":"nurlanvalizada/NLBInjecto","owner":"nurlanvalizada","description":"Custom, lightweight, extensible, and testable dependency injection (DI) container for .NET applications. Built from scratch to help you understand DI internals, customize registrations, and extend behavior beyond the built-in .NET DI framework","archived":false,"fork":false,"pushed_at":"2025-01-06T04:50:59.000Z","size":43,"stargazers_count":36,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-03T05:40:30.071Z","etag":null,"topics":["aspnetcore","csharp","dependency-injection","dotnet"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/NLBInjecto","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nurlanvalizada.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-17T06:38:58.000Z","updated_at":"2025-09-20T06:22:55.000Z","dependencies_parsed_at":"2025-01-04T18:28:01.022Z","dependency_job_id":"7c24406b-2e4b-4b3e-af01-3f7a83ddb9d8","html_url":"https://github.com/nurlanvalizada/NLBInjecto","commit_stats":null,"previous_names":["nurlanvalizada/nlbinjecto"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nurlanvalizada/NLBInjecto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurlanvalizada%2FNLBInjecto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurlanvalizada%2FNLBInjecto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurlanvalizada%2FNLBInjecto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurlanvalizada%2FNLBInjecto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nurlanvalizada","download_url":"https://codeload.github.com/nurlanvalizada/NLBInjecto/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurlanvalizada%2FNLBInjecto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28410086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnetcore","csharp","dependency-injection","dotnet"],"created_at":"2026-01-14T05:01:32.183Z","updated_at":"2026-01-14T05:01:33.009Z","avatar_url":"https://github.com/nurlanvalizada.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NLBInjecto - Lightweight DI Container\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![NuGet](https://img.shields.io/badge/nuget-1.0.0-blue.svg)](https://www.nuget.org/packages/NLBInjecto/1.0.0)\n\nNlbInjecto is a **custom**, **lightweight**, **extensible**, and **testable** dependency injection (DI) container for .NET applications. Built from scratch to help you **understand** DI internals, **customize** registrations, and **extend** behavior beyond the built-in .NET DI framework.\n\n## Table of Contents\n\n- [NLBInjecto - Lightweight DI Container](#nlbinjecto---lightweight-di-container)\n  - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n  - [Motivation](#motivation)\n  - [Installation](#installation)\n  - [Getting Started](#getting-started)\n    - [Basic Registration \\\u0026 Resolution](#basic-registration--resolution)\n    - [Open Generic Registration](#open-generic-registration)\n    - [Decorators](#decorators)\n    - [Scopes](#scopes)\n    - [Keyed Services](#keyed-services)\n  - [Contributing](#contributing)\n    - [How to Contribute](#how-to-contribute)\n  - [License](#license)\n\n---\n\n## Features\n\n- **Open Generic Support**  \n  Register types like `IGenericService\u003cT\u003e` -\u003e `GenericService\u003cT\u003e` and let the container resolve any closed generic at runtime.\n\n- **Decorator Support**  \n  Easily wrap services with decorators (e.g., logging, caching, or cross-cutting concerns) for both non-generic and open-generic services.\n\n- **Multiple Lifetimes**  \n  Supports Singleton, Scoped, and Transient lifetimes. Control exactly how and when your services are instantiated.\n\n- **Named Registrations**  \n  Optionally register services with a name to allow multiple implementations of the same interface.\n\n- **Resolving service with most parametered contructor**\n  When resolving services NLBInjecto takes contructor with most parameters\n\n- **Testable**  \n  Includes comprehensive unit tests demonstrating behavior and best practices.\n\n---\n\n## Motivation\n\nMy motivation for built such repository is to show how we can build complex systems step by step. Maybe this is not a complete solution but it offer most of the functionality which modern DI containers offer. \n\n---\n\n## Installation\n\n1. Clone or download the repository.\n2. Open the solution in Visual Studio or JetBrains Rider.\n3. Build the project. You’re set to include this library in your application.\n\n*(Alternatively, it is available as a NuGet package. You can add it to your projects like this `dotnet add package NLBInjecto`.)*\n\n---\n\n## Getting Started\n\n### Basic Registration \u0026 Resolution\n\n```csharp\nvar services = new NlbServiceCollection();\n\n// Register: IMyService -\u003e MyService\nservices.AddScoped\u003cIMyService, MyService\u003e();\n\n// Build the provider\nvar provider = services.BuildServiceProvider();\n\n// Resolve\nvar myService = provider.GetService\u003cIMyService\u003e();\nmyService.DoWork();\n```\n\n### Open Generic Registration\n\n```csharp\nvar services = new NlbServiceCollection();\n\n// Register open generic: IGenericService\u003cT\u003e -\u003e GenericService\u003cT\u003e\nservices.AddSingleton(typeof(IGenericService\u003c\u003e), typeof(GenericService\u003c\u003e));\n\nvar provider = services.BuildServiceProvider();\n\n// Resolve closed generics\nvar intService = provider.GetService\u003cIGenericService\u003cint\u003e\u003e();\nvar stringService = provider.GetService\u003cIGenericService\u003cstring\u003e\u003e();\n\nConsole.WriteLine(intService.GetValue());\nConsole.WriteLine(stringService.GetValue());\n```\n\n### Decorators\n\n```csharp\nvar services = new NlbServiceCollection();\n\n// Base registration\nservices.AddScoped\u003cIOrderService, OrderService\u003e();\n\n// Decorator registration\nservices.AddDecorator\u003cIOrderService, OrderServiceLoggingDecorator\u003e();\n\nvar provider = services.BuildServiceProvider();\n\nvar orderService = provider.GetService\u003cIOrderService\u003e(); \n// -\u003e Actually returns OrderServiceLoggingDecorator \n//    that wraps the real OrderService\n```\n\nAnd for **open generics**:\n```csharp\nservices.AddScoped(typeof(IGenericService\u003c\u003e), typeof(GenericService\u003c\u003e));\nservices.AddDecorator(typeof(IGenericService\u003c\u003e), typeof(GenericServiceDecorator\u003c\u003e));\n```\n\n### Scopes\n\n```csharp\nvar services = new NlbServiceCollection();\nservices.AddScoped\u003cIMyService, MyService\u003e();\n\nvar provider = services.BuildServiceProvider();\n\n// Create first scope\nusing (var scopeA = provider.CreateScope())\n{\n    var serviceA1 = scopeA.ServiceProvider.GetService\u003cIMyService\u003e();\n    var serviceA2 = scopeA.ServiceProvider.GetService\u003cIMyService\u003e();\n    // serviceA1 == serviceA2 (same scope, same instance if scoped)\n}\n\n// Create second scope\nusing (var scopeB = provider.CreateScope())\n{\n    var serviceB1 = scopeB.ServiceProvider.GetService\u003cIMyService\u003e();\n    // serviceB1 != serviceA1 (different scope, new instance)\n}\n```\n\n### Keyed Services\n\n```csharp\nvar services = new NlbServiceCollection();\n\nservices.AddTransient\u003cITransientService, TransientService\u003e(\"test\");\nservices.AddDecorator\u003cITransientService, TransientServiceDecorator\u003e();\n\nvar provider = services.BuildServiceProvider();\n\nvar transientService = serviceProvider.GetService\u003cITransientService\u003e(\"test\");\n// transientService here is TransientService\n```\n\n## Contributing\n\n**Contributions are welcome!** I’d love to see **pull requests** for:\n\n- New features (e.g., advanced constructor injection, property injection).  \n- Bug fixes if you find any.  \n- Enhancements to documentation or samples.  \n- Performance improvements.\n\n### How to Contribute\n\n1. **Fork** this repository and **clone** it locally.  \n2. Create a new **branch** for your feature or fix.  \n3. **Commit** your changes with clear messages.  \n4. Push the branch to your **fork**.  \n5. Open a **Pull Request** from your fork’s branch to this repository’s `main` branch.  \n6. Once reviewed, I’ll **merge** your changes.\n\nFeel free to open an **issue** if you find a bug or have a feature request.\n\n\n## License\nThis project is licensed under the [MIT LICENSE](LICENSE). You are free to use it in both commercial and open-source software.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnurlanvalizada%2Fnlbinjecto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnurlanvalizada%2Fnlbinjecto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnurlanvalizada%2Fnlbinjecto/lists"}