HerrGeneral.Core
1.3.0
dotnet add package HerrGeneral.Core --version 1.3.0
NuGet\Install-Package HerrGeneral.Core -Version 1.3.0
<PackageReference Include="HerrGeneral.Core" Version="1.3.0" />
<PackageVersion Include="HerrGeneral.Core" Version="1.3.0" />
<PackageReference Include="HerrGeneral.Core" />
paket add HerrGeneral.Core --version 1.3.0
#r "nuget: HerrGeneral.Core, 1.3.0"
#:package HerrGeneral.Core@1.3.0
#addin nuget:?package=HerrGeneral.Core&version=1.3.0
#tool nuget:?package=HerrGeneral.Core&version=1.3.0
HerrGeneral.Core
Essential components for application integration and configuration
Registration with Dependency Injection
Herr General integrates seamlessly with .NET's dependency injection system using Microsoft.Extensions.DependencyInjection. Configure the framework in your application startup with a fluent API:
// Add Herr General to your service collection
services.UseHerrGeneral(configuration =>
configuration
// Register write side assembly and namespace for command and domain event handlers
.UseWriteSideAssembly(typeof(Person).Assembly, typeof(Person).Namespace!)
// Register read side assembly and namespace for read model event handlers
.UseReadSideAssembly(typeof(PersonFriendRM).Assembly, typeof(PersonFriendRM).Namespace!));
This registration process scans the specified assemblies for command handlers and event handlers, registering them with the appropriate lifetime scopes in the dependency injection container.
Mediator
Send your commands with the mediator:
var mediator = serviceProvider.getRequiredService<Mediator>;
var result = mediator.Send(new MyCommand());
External Handler Integration
Herr General provides a comprehensive set of configuration methods to integrate existing handlers or third-party components that don't follow the standard conventions. This flexibility is essential when working with legacy systems or external libraries.
Command Handler Integration Methods
The Configuration class offers several methods to adapt different types of external command handlers:
1. Simple Command Handler Registration
For handlers that already return events in the expected format (IEnumerable<object>):
services.UseHerrGeneral(config =>
config.MapCommandHandler<MyCommand, ExternalCommandHandler>());
How it works:
- Registers
ExternalCommandHandleras the handler forMyCommand - The handler's return value is used directly as the event collection
- Suitable for handlers that already return a collection of events
2. Command Handler with Event Mapping
For handlers that return a custom result type that needs transformation:
services.UseHerrGeneral(config =>
config.MapCommandHandler<MyCommand, ExternalCommandHandler, CustomResult>(
// Transform function: converts the handler result into events
result => result.MyEvents
));
How it works:
- The handler returns a custom type (
CustomResult) - The provided mapping function transforms this result into a collection of events
- Enables integration with handlers that don't directly produce events
3. Command Handler with Value Return
For handlers that need to produce both events and a specific return value (especially useful for creation commands):
services.UseHerrGeneral(config =>
config.MapCommandHandler<CreateEntity, ExternalCreateHandler, CustomResult, Guid>(
// Event mapping function
result => result.MyEvents,
// Value mapping function
result => result.Id // Returns the ID to the caller
));
How it works:
- The first function maps the handler result to domain events
- The second function extracts a specific value from the result to return to the caller
- Perfect for creation commands where you need to return the new entity's ID
- The extracted value is wrapped in a
Result<TValue>for consistent error handling
Event Handler Integration
Event handlers can also be externally registered for both write and read sides:
Write Side Event Handlers
services.UseHerrGeneral(config =>
config.MapEventHandlerOnWriteSide<PaymentReceived, UpdateAccountBalanceHandler>());
Purpose: Register handlers that perform domain logic in response to events (may generate additional events).
Read Side Event Handlers
services.UseHerrGeneral(config =>
config.MapEventHandlerOnReadSide<OrderShipped, UpdateShippingStatisticsHandler>());
Purpose: Register handlers that update read models and projections (should not produce new events).
Domain Exception Registration
Herr General distinguishes between technical failures and business rule violations by registering domain exceptions:
services.UseHerrGeneral(config =>
config.UseDomainException<InsufficientFundsException>());
Benefits:
- Registered exceptions are treated as expected business outcomes rather than system errors
- They are automatically wrapped in a
DomainErrorresult instead of anExceptionresult - Provides a cleaner separation between technical failures and business rule violations
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- HerrGeneral.ReadSide (>= 1.3.0)
- HerrGeneral.WriteSide (>= 1.3.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.SourceLink.GitHub (>= 8.0.0)
- MinVer (>= 6.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on HerrGeneral.Core:
| Package | Downloads |
|---|---|
|
HerrGeneral.Test.Extension
Helper methods for HerrGeneral testing |
|
|
HerrGeneral.Core.DDD
Registration of dynamic handler for aggregate creation and update |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.0 | 685 | 12/1/2025 |
| 1.2.1-alpha.0.2 | 381 | 11/30/2025 |
| 1.0.1-alpha.0.3 | 358 | 11/20/2025 |
| 0.1.26-rc | 304 | 11/11/2025 |
| 0.1.25-rc | 217 | 9/25/2025 |
| 0.1.24-rc | 162 | 9/12/2025 |
| 0.1.23-rc | 215 | 9/11/2025 |
| 0.1.22-rc | 205 | 9/11/2025 |
| 0.1.21-rc | 130 | 8/23/2025 |
| 0.1.20-rc | 279 | 8/7/2025 |
| 0.1.19-rc | 289 | 8/6/2025 |
| 0.1.18-rc | 116 | 8/1/2025 |
| 0.1.17-rc | 206 | 7/13/2025 |
| 0.1.16-rc | 147 | 7/4/2025 |
| 0.1.15-rc | 218 | 7/1/2025 |
| 0.1.14-rc | 168 | 6/28/2025 |
| 0.1.13-rc | 152 | 11/12/2024 |
| 0.1.9-rc | 191 | 9/21/2023 |
| 0.1.8-rc | 195 | 9/19/2023 |
| 0.1.7-rc | 199 | 9/11/2023 |
| 0.1.6-rc | 216 | 8/8/2023 |
| 0.1.5-rc | 215 | 8/6/2023 |
| 0.1.4-rc | 205 | 8/6/2023 |
| 0.1.3-rc | 216 | 8/6/2023 |