PANiXiDA.Core.Application is a .NET library with application-layer abstractions for Clean Architecture, CQRS, and DDD-based services.
It defines contracts and small reusable building blocks for commands, queries, request behaviors, domain event publishing, unit-of-work orchestration, repositories, aggregate tracking, and read-side paging helpers. The package intentionally does not provide a concrete mediator, database provider, dependency injection module, or transport-specific implementation.
- CQRS request contracts:
ICommand<TResult>,IQuery<TResult>, andIRequest<TResult>. - Mediator contracts for command/query dispatch and handler implementation.
- Pipeline behavior contracts for before, after, and finally request stages.
- Built-in behaviors for transaction start, save, commit, cleanup, and domain event publishing.
- Event bus and event handler abstractions for
DomainEventintegration. - Unit of work, repository, and aggregate tracker abstractions for DDD persistence boundaries.
- Read-side helper models for page-based pagination, cursor pagination, sorting, and filtering.
- .NET 10 SDK
- Nullable reference types enabled in consuming projects is recommended
<ItemGroup>
<PackageReference Include="PANiXiDA.Core.Application" Version="1.0.0" />
</ItemGroup>using PANiXiDA.Core.Application.Messaging.Mediator.Contracts;
using PANiXiDA.Core.Application.Messaging.Mediator.Handlers;
using PANiXiDA.Core.ResultPattern;
public sealed record PingCommand : ICommand<Result>;
public sealed class PingCommandHandler : ICommandHandler<PingCommand, Result>
{
public Task<Result> HandleAsync(
PingCommand command,
CancellationToken cancellationToken)
{
return Task.FromResult(Result.Success());
}
}using PANiXiDA.Core.Application.Messaging.Mediator.Contracts;
using PANiXiDA.Core.Application.Messaging.Mediator.Handlers;
using PANiXiDA.Core.ResultPattern;
public sealed record GetNameQuery(Guid Id) : IQuery<Result<string>>;
public sealed class GetNameQueryHandler : IQueryHandler<GetNameQuery, Result<string>>
{
public Task<Result<string>> HandleAsync(
GetNameQuery query,
CancellationToken cancellationToken)
{
return Task.FromResult(Result.Success("PANiXiDA"));
}
}using PANiXiDA.Core.Application.Querying.Pagination;
var result = PaginationResult<string>.Create(
items: ["first", "second"],
pageNumber: 1,
pageSize: 10,
totalCount: 2);
var hasNextPage = result.HasNextPage;using PANiXiDA.Core.Application.Querying.Cursor;
var result = CursorPaginationResult<string>.Create(
items: ["first", "second"],
limit: 10,
nextCursor: "cursor-2",
hasNextPage: true);The package includes reusable mediator behavior implementations for command transaction orchestration and domain event publication:
BeginTransactionBehavior<TCommand, TResult>starts a transaction before a command handler runs.SaveChangesBehavior<TCommand, TResult>persists changes after a successful command result when a transaction is active.PublishDomainEventsBehavior<TRequest, TResult>publishes domain events collected from tracked aggregate roots after a successful request result and clears tracked events after a failed result or completed successful publication.CommitTransactionBehavior<TCommand, TResult>commits the active transaction after a successful command result.CleanupTransactionBehavior<TCommand, TResult>rolls back failed command transactions and disposes transaction resources.
A consuming mediator implementation should register these behaviors in a deterministic order. A typical command pipeline is:
before: BeginTransactionBehavior
handler: ICommandHandler<TCommand, TResult>
after: SaveChangesBehavior
after: PublishDomainEventsBehavior
after: CommitTransactionBehavior
finally: CleanupTransactionBehavior
The exact registration mechanism depends on the mediator or composition root used by the consuming application.
IMediatordispatches commands and queries.ICommandHandler<TCommand, TResult>handles state-changing requests.IQueryHandler<TQuery, TResult>handles read-only requests.IBeforeRequestBehavior<TRequest, TResult>runs before a handler and is defined in the mediator behavior abstractions namespace.IAfterRequestBehavior<TRequest, TResult>runs after a handler returns a result and is defined in the mediator behavior abstractions namespace.IFinallyRequestBehavior<TRequest, TResult>runs after request processing completes or fails and is defined in the mediator behavior abstractions namespace.
IEventBuspublishes domain events.IEventHandler<TEvent>handles a specific domain event type.IAggregateTrackertracks aggregate roots touched during a request so their domain events can be published and cleared.
IUnitOfWorkdefines persistence and transaction operations.IRepository<TId, TAggregateRoot>defines basic aggregate persistence operations.IReadRepository<TId>defines read-only existence checks.
PaginationParameterscalculatesSkipandTakefor page-based reads.PaginationResult<TItem>returns page metadata and items.CursorPaginationParametersrepresents cursor pagination input.CursorPaginationResult<TItem>returns cursor pagination metadata and items.SortParametersandSortOrderrepresent read sorting options.FilterParametersis the base type for custom read filter records.
The package does not require runtime configuration. Consumers provide concrete implementations for mediator dispatch, persistence, event bus delivery, aggregate tracking, and dependency injection registration.
dotnet restoredotnet formatdotnet build --configuration Releasedotnet test --configuration Releasedotnet pack --configuration Release.
├── src/
│ └── PANiXiDA.Core.Application/
├── tests/
│ └── PANiXiDA.Core.Application.UnitTests/
├── Directory.Build.props
├── Directory.Build.targets
├── Directory.Packages.props
├── global.json
├── version.json
├── icon.png
├── LICENSE
└── README.md
This project is licensed under the Apache-2.0 license. See the LICENSE file for details.