Athenex.Whimclean.Infrastructure
2.0.0
Prefix Reserved
dotnet add package Athenex.Whimclean.Infrastructure --version 2.0.0
NuGet\Install-Package Athenex.Whimclean.Infrastructure -Version 2.0.0
<PackageReference Include="Athenex.Whimclean.Infrastructure" Version="2.0.0" />
<PackageVersion Include="Athenex.Whimclean.Infrastructure" Version="2.0.0" />
<PackageReference Include="Athenex.Whimclean.Infrastructure" />
paket add Athenex.Whimclean.Infrastructure --version 2.0.0
#r "nuget: Athenex.Whimclean.Infrastructure, 2.0.0"
#:package Athenex.Whimclean.Infrastructure@2.0.0
#addin nuget:?package=Athenex.Whimclean.Infrastructure&version=2.0.0
#tool nuget:?package=Athenex.Whimclean.Infrastructure&version=2.0.0
Athenex.Whimclean.Infrastructure
Provider-neutral infrastructure building blocks used by the Whimclean EF Core integration: audit actor resolution, the in-process domain-event pipeline, and deterministic seed identifiers.
Install
dotnet add package Athenex.Whimclean.Infrastructure
Audit actor resolution
IAuditActorResolver<TUserId, TActor> (in Athenex.Whimclean.Infrastructure.Auditing) converts the authenticated user identifier into the representation stored by audit columns.
For a Guid user ID stored in nullable Guid? audit properties:
using Athenex.Whimclean.Infrastructure;
services.AddNullableAuditActorResolver<Guid>();
When the types are identical and non-nullable:
services.AddIdentityAuditActorResolver<Guid>();
Both helpers register a singleton with TryAdd semantics (NullableAuditActorResolver<TUserId> requires a value type; IdentityAuditActorResolver<TActor> returns the id unchanged). Implement the interface yourself when audit actors require mapping to a name, service account, or value object:
using Athenex.Whimclean.Infrastructure.Auditing;
services.AddSingleton<
IAuditActorResolver<Guid, ActorStamp>,
ActorStampResolver>();
Domain-event pipeline
The package ships an in-process pipeline in Athenex.Whimclean.Infrastructure.DomainEvents: IDomainEventDispatcher delivers each committed event to every IDomainEventHandler<TEvent> registered for its runtime type. The unit of work invokes the dispatcher after a successful commit, so a handler failure never rolls the persisted changes back.
using Athenex.Whimclean.Infrastructure;
services.AddDomainEventDispatcher();
services.AddDomainEventHandler<OrderPlaced, SendConfirmationEmail>();
services.AddDomainEventHandler<OrderPlaced, ReserveStock>();
AddDomainEventDispatcher registers ServiceProviderDomainEventDispatcher as a scoped service with TryAdd semantics; AddDomainEventHandler registers the handler as scoped with TryAddEnumerable, so several handlers may react to one event while duplicate registrations collapse to one.
using Athenex.Whimclean.Application.Email;
using Athenex.Whimclean.Infrastructure.DomainEvents;
public sealed class SendConfirmationEmail(IEmailSender emailSender)
: IDomainEventHandler<OrderPlaced>
{
public Task HandleAsync(
OrderPlaced domainEvent,
CancellationToken cancellationToken = default) =>
emailSender.SendAsync(
new EmailMessage(
"member@example.com",
"Order confirmed",
$"Order {domainEvent.OrderId} has been placed."),
cancellationToken);
}
Dispatch failures
When a handler throws after the commit succeeded, the save surfaces a DomainEventDispatchException. The save must not be retried — the data is already persisted; the events that never reached their handlers are on UndeliveredEvents (the failing event first, then any never attempted), ready to be handled or replayed. The EF Core unit of work clears each aggregate's events before dispatching, so events raised by a handler during dispatch survive for the next commit, and it dispatches with CancellationToken.None so a cancelled request cannot abort delivery for changes that are already persisted.
Bridging to a mediator
The default dispatcher is replaceable: register your own IDomainEventDispatcher (before or instead of AddDomainEventDispatcher — TryAdd leaves it in place) to bridge into a mediator or message dispatcher. The example below targets a MediatR-style IMediator whose Publish accepts any object:
using Athenex.Whimclean.Domain.Events;
using Athenex.Whimclean.Infrastructure.DomainEvents;
public sealed class MediatorDomainEventDispatcher(IMediator mediator)
: IDomainEventDispatcher
{
public Task DispatchAsync(
IDomainEvent domainEvent,
CancellationToken cancellationToken = default) =>
mediator.Publish(domainEvent, cancellationToken);
}
services.AddScoped<IDomainEventDispatcher, MediatorDomainEventDispatcher>();
For the source-generated martinothamar/Mediator, the Athenex.Whimclean.Mediator package already ships this bridge as AddMediatorDomainEventDispatcher(); see its README.
This package deliberately does not select MediatR, EF Core, a database provider, Identity, or multitenancy.
Deterministic seed identifiers
DeterministicGuid.Create(parentId, key) (in Athenex.Whimclean.Infrastructure.Seeding) derives a stable identifier from a parent id and a key by hashing them with SHA-256, so seeded rows such as system roles get the same id in every environment and seeders stay idempotent. The Create(key) overload uses Guid.Empty as the parent for top-level seed rows:
using Athenex.Whimclean.Infrastructure.Seeding;
var ownerRoleId = DeterministicGuid.Create(tenantId, "owner");
Repository and full architecture guide: https://github.com/athene-x/Whimclean
| 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
- Athenex.Whimclean.Domain (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Athenex.Whimclean.Infrastructure:
| Package | Downloads |
|---|---|
|
Athenex.Whimclean.Infrastructure.EntityFrameworkCore
Provider-neutral EF Core infrastructure for Whimclean applications, including required current-user writes, shadow-property audit stamps and soft deletion (HasAuditStamps, HasSoftDelete), concurrency handling, unit-of-work registration, list query helpers, and domain-event dispatch. |
|
|
Athenex.Whimclean.Mediator
Optional Mediator (martinothamar/Mediator) integration: a command unit-of-work pipeline behavior and domain-event delivery as mediator notifications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 160 | 11/17/2026 |
2.0.0: first nuget.org release. Provider-neutral audit actor resolution, the in-process domain-event pipeline with asynchronous dispatch, and DeterministicGuid for stable seed identifiers.