Core application layer abstractions, CQRS interfaces, and handler registration extensions for Clean Architecture. Includes ICommand, IQuery, IMediator interfaces, event handlers, and DI extensions for automatic handler discovery and registration.
$ dotnet add package Mohd2sh.CleanArchitecture.Core.ApplicationCore application layer abstractions, CQRS interfaces, and handler registration extensions for Clean Architecture.
This package provides CQRS abstractions (commands, queries, mediator) and dependency injection extensions for automatic handler discovery and registration.
dotnet add package Mohd2sh.CleanArchitecture.Core.Application
services.AddApplicationHandlers(typeof(YourApplication.ServiceCollectionExtensions).Assembly);
public record CreateProductCommand(string Name) : ICommand<Result<Guid>>;
public class CreateProductCommandHandler : ICommandHandler<CreateProductCommand, Result<Guid>>
{
public Task<Result<Guid>> Handle(CreateProductCommand request, CancellationToken cancellationToken)
{
// Implementation
}
}
public record GetProductQuery(Guid Id) : IQuery<Result<ProductDto>>;
public class GetProductQueryHandler : IQueryHandler<GetProductQuery, Result<ProductDto>>
{
public Task<Result<ProductDto>> Handle(GetProductQuery request, CancellationToken cancellationToken)
{
// Implementation
}
}
public class OrderCreatedEventHandler : IDomainEventHandler<OrderCreatedEvent>
{
public Task Handle(OrderCreatedEvent @event, CancellationToken cancellationToken)
{
// Implementation
}
}
public class OrderCompletedEventHandler : IIntegrationEventHandler<OrderCompletedEvent>
{
public Task Handle(OrderCompletedEvent @event, CancellationToken cancellationToken)
{
// Implementation
}
}
ICommand<TResult> - Command interfaceIQuery<TResult> - Query interfaceIMediator - Mediator interface for sending commands and queriesICommandHandler<TCommand, TResult> - Command handler interfaceIQueryHandler<TQuery, TResult> - Query handler interfaceIDomainEventHandler<TEvent> - Domain event handler interfaceIIntegrationEventHandler<TEvent> - Integration event handler interfaceGitHub: https://github.com/mohd2sh/CleanArchitecture-DDD-CQRS
MIT