Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 1.48 KB

CommandQuery.Abstractions.md

File metadata and controls

57 lines (42 loc) · 1.48 KB

CommandQuery.Abstractions ⚙️

build CodeFactor

Command Query Separation abstractions for .NET and C#

Commands

public interface ICommand;

public interface ICommand<TResult>;
public interface ICommandHandler<in TCommand>
    where TCommand : ICommand
{
    Task HandleAsync(TCommand command, CancellationToken cancellationToken);
}

public interface ICommandHandler<in TCommand, TResult>
    where TCommand : ICommand<TResult>
{
    Task<TResult> HandleAsync(TCommand command, CancellationToken cancellationToken);
}

Queries

public interface IQuery<TResult>;
public interface IQueryHandler<in TQuery, TResult>
    where TQuery : IQuery<TResult>
{
    Task<TResult> HandleAsync(TQuery query, CancellationToken cancellationToken);
}

Error

public interface IError
{
    public string? Message { get; }

    public Dictionary<string, object>? Details { get; }
}

Samples