DelegatR is a minimal, in-process mediator for .NET.
It provides a small set of contracts plus a single default runtime Mediator implementation that can dispatch requests and publish notifications. Resolution is DI-agnostic via a ServiceFactory delegate.
Send:- Dispatch a request to exactly one handler
- Optional pipeline behaviors that wrap the handler
- Cancellation token flows through behaviors and handler
Publish:- Resolve all handlers for the concrete notification type
- Execute sequentially in resolver order
- Stop on the first exception
ServiceFactory:- A delegate-based abstraction for resolving services from any container (or your own resolver)
- Streaming requests / async enumerable responses
- Advanced publish strategies (parallelism, exception aggregation, fire-and-forget)
- Assembly scanning / auto-registration helpers
- Built-in logging/metrics (use pipeline behaviors instead)
- Licensing or license enforcement
- Define a request type that implements
IRequest<TResponse>. - Implement a handler for it using
IRequestHandler<TRequest, TResponse>. - (Optional) Register one or more
IPipelineBehavior<TRequest, TResponse>to wrapSend. - Provide a
ServiceFactorythat can resolve:- The request handler for the concrete request type
- The pipeline behavior sequence for that request type
- The notification handlers sequence for the concrete notification type
- Create
new Mediator(factory)and callSend/Publish.
The library is designed to be packed as a NuGet package from src/DelegatR.
See examples/DelegatR.Examples.Console for a small console app demonstrating:
Sendwith a request/handlerPublishwith two notification handlers (sequential execution)- A simple pipeline behavior wrapping
Send
documents/why-delegatr.mddocuments/migration-notes.md
MIT is recommended for this repository (add a LICENSE file when ready).