LiteBus.Extensions.MicrosoftDependencyInjection
1.0.0
See the version list below for details.
dotnet add package LiteBus.Extensions.MicrosoftDependencyInjection --version 1.0.0
NuGet\Install-Package LiteBus.Extensions.MicrosoftDependencyInjection -Version 1.0.0
<PackageReference Include="LiteBus.Extensions.MicrosoftDependencyInjection" Version="1.0.0" />
<PackageVersion Include="LiteBus.Extensions.MicrosoftDependencyInjection" Version="1.0.0" />
<PackageReference Include="LiteBus.Extensions.MicrosoftDependencyInjection" />
paket add LiteBus.Extensions.MicrosoftDependencyInjection --version 1.0.0
#r "nuget: LiteBus.Extensions.MicrosoftDependencyInjection, 1.0.0"
#:package LiteBus.Extensions.MicrosoftDependencyInjection@1.0.0
#addin nuget:?package=LiteBus.Extensions.MicrosoftDependencyInjection&version=1.0.0
#tool nuget:?package=LiteBus.Extensions.MicrosoftDependencyInjection&version=1.0.0
<h1 align="center"><br> <a href="https://github.com/litenova/LiteBus"> <img src="assets/logo/icon.png"> </a> <br> LiteBus <br> </h1> <h4 align="center">A lightweight, flexible in-process mediator for implementing Command Query Separation (CQS)</h4> <p align="center"> <a href="https://github.com/litenova/LiteBus/actions/workflows/release.yml"> <img src="https://github.com/litenova/LiteBus/actions/workflows/release.yml/badge.svg" alt="CI/CD Badge" /> </a> <a href="https://codecov.io/gh/litenova/LiteBus" > <img src="https://codecov.io/gh/litenova/LiteBus/graph/badge.svg?token=XBNYITSV5A" alt="Code Coverage Badge" /> </a> <a href="https://www.nuget.org/packages/LiteBus"> <img src="https://img.shields.io/nuget/vpre/LiteBus.svg" alt="LiteBus Nuget Version" /> </a> </p> <p align="center"> For detailed documentation and examples, please visit the <a href="https://github.com/litenova/LiteBus/wiki"><b>Wiki</b></a>. </p>
Key Features
Built for .NET 8 - Designed to leverage modern C# and .NET capabilities
Zero external dependencies - Completely standalone with no third-party dependencies
Reduced reflection usage - Optimized for performance with minimal reflection
DDD-friendly design - Support for plain domain events without framework dependencies, keeping your domain model clean
Comprehensive messaging types:
ICommand/ICommand<TResult>- For state-changing operationsIQuery<TResult>- For data retrieval operationsIStreamQuery<TResult>- For streaming large datasets viaIAsyncEnumerable<T>IEvent- For notifications and event-driven architecture- Support for POCO objects as messages without framework interfaces
Rich handler ecosystem:
- Pre-handlers for validation and pre-processing
- Post-handlers for notifications and side effects
- Error handlers for centralized exception management
- Support for generic handlers and messages
- Handler ordering control
- Contextual handler selection via tags and filters
Advanced features:
- Covariant type handling for polymorphic dispatch
- Execution context for cross-cutting concerns
- Aborting execution flow when needed
- Microsoft Dependency Injection integration
Quick Example
// Define a command with a result
public class CreateProductCommand : ICommand<ProductDto>
{
public required string Name { get; init; }
public required decimal Price { get; init; }
public string? Description { get; init; }
}
// Implement a command handler
public class CreateProductCommandHandler : ICommandHandler<CreateProductCommand, ProductDto>
{
private readonly IProductRepository _repository;
public CreateProductCommandHandler(IProductRepository repository)
{
_repository = repository;
}
public async Task<ProductDto> HandleAsync(CreateProductCommand command, CancellationToken cancellationToken = default)
{
var product = new Product
{
Id = Guid.NewGuid(),
Name = command.Name,
Price = command.Price,
Description = command.Description
};
await _repository.SaveAsync(product, cancellationToken);
return new ProductDto
{
Id = product.Id,
Name = product.Name,
Price = product.Price,
Description = product.Description
};
}
}
// Configure in ASP.NET Core
services.AddLiteBus(liteBus =>
{
liteBus.AddCommandModule(module =>
{
module.RegisterFromAssembly(typeof(Program).Assembly);
});
liteBus.AddQueryModule(module =>
{
module.RegisterFromAssembly(typeof(Program).Assembly);
});
liteBus.AddEventModule(module =>
{
module.RegisterFromAssembly(typeof(Program).Assembly);
});
});
// Use in a controller or service
public class ProductsController : ControllerBase
{
private readonly ICommandMediator _commandMediator;
public ProductsController(ICommandMediator commandMediator)
{
_commandMediator = commandMediator;
}
[HttpPost]
public async Task<ActionResult<ProductDto>> CreateProduct(CreateProductCommand command)
{
var product = await _commandMediator.SendAsync(command);
return Ok(product);
}
}
Documentation
For comprehensive documentation, including detailed explanations, advanced features, and best practices, please visit the Wiki.
Installation
LiteBus is available as NuGet packages:
dotnet add package LiteBus
dotnet add package LiteBus.Extensions.MicrosoftDependencyInjection
Or specific modules:
dotnet add package LiteBus.Commands
dotnet add package LiteBus.Queries
dotnet add package LiteBus.Events
License
LiteBus is licensed under the MIT License. See the LICENSE file for details.
| 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. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on LiteBus.Extensions.MicrosoftDependencyInjection:
| Repository | Stars |
|---|---|
|
EdiWang/Moonglade
Blog system of https://edi.wang, runs on Microsoft Azure
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.1.0 | 10,792 | 8/5/2025 |
| 3.0.0 | 4,636 | 7/21/2025 |
| 2.2.3 | 2,357 | 7/18/2025 |
| 2.2.2 | 178 | 7/18/2025 |
| 2.2.1 | 3,701 | 7/8/2025 |
| 2.2.0 | 238 | 7/8/2025 |
| 2.1.0 | 246 | 7/1/2025 |
| 2.0.0 | 3,301 | 4/29/2025 |
| 1.1.0 | 225 | 4/24/2025 |
| 1.0.0 | 161 | 4/19/2025 |
| 0.25.1 | 256 | 4/17/2025 |
| 0.25.0 | 241 | 4/13/2025 |
| 0.24.4 | 231 | 4/10/2025 |
| 0.24.3 | 2,655 | 5/2/2024 |
| 0.24.2 | 245 | 4/16/2024 |
| 0.24.1 | 205 | 1/30/2024 |
| 0.23.1 | 1,704 | 1/11/2024 |
| 0.23.0 | 233 | 12/23/2023 |
| 0.22.0 | 208 | 12/23/2023 |