Caesar

Caesar is a lightweight in-process mediator for .NET 10. Requests go to exactly one handler, notifications go to every handler, and a pipeline of behaviors wraps each request. It is wired through Microsoft.Extensions.DependencyInjection and designed for Clean Architecture solutions where the Application layer must stay free of infrastructure concerns.

Package Reference it from Contents
Caesar.Abstractions Application layer Requests, notifications, streams, handler and behavior interfaces, ISender / IPublisher / IMediator, Unit. No dependencies.
Caesar API / composition root Mediator, publish strategies, built-in behaviors and services.AddCaesar(...).

Install

dotnet add src/MyApp.Application package Caesar.Abstractions
dotnet add src/MyApp.Api package Caesar

In 30 seconds

Define a request and its handler in the Application layer:

public sealed record CreateCustomer(string Name, string Email) : IRequest<Guid>;

public sealed class CreateCustomerHandler(ICustomerRepository repository) : IRequestHandler<CreateCustomer, Guid>
{
    public async Task<Guid> Handle(CreateCustomer request, CancellationToken cancellationToken)
    {
        var customer = new Customer(Guid.NewGuid(), request.Name, request.Email);
        await repository.Save(customer, cancellationToken);
        return customer.Id;
    }
}

Register Caesar in the composition root:

services.AddCaesar(cfg => cfg.RegisterServicesFromAssemblyContaining<CreateCustomer>());

Send it from anywhere that can inject ISender:

public sealed class CustomerEndpoints(ISender sender)
{
    public Task<Guid> Create(CreateCustomer command, CancellationToken cancellationToken)
        => sender.Send(command, cancellationToken);

    public Task Deactivate(Guid id, CancellationToken cancellationToken)
        => sender.Send(new DeactivateCustomer(id), cancellationToken);
}

Next steps