Skip to main content

Builders

Namespace: RA.Utilities.Dispatcher.Builders

The RA.Utilities.Dispatcher.Builders namespace holds the fluent builders returned by AddDispatcher / AddNotification. They implement the Builder Pattern: each configuration call returns the builder, so you define an entire vertical slice in a single, coherent block of code.

🏗️ Available Builders​

BuilderReturned ByConfigures
DispatcherBuilder<TRequest>AddDispatcher<TRequest, THandler>()Behaviors and validators for a request without a response
DispatcherBuilder<TRequest, TResponse>AddDispatcher<TRequest, TResponse, THandler>()Behaviors and validators for a request with a response
NotificationDispatcherBuilder<TNotification>AddNotification<TNotification>()Handlers and behaviors for a notification

All three implement IDispatcherBuilder and expose the IServiceCollection being configured.

🚀 Example​

_ = services
.AddDispatcher<CreateProductCommand, int, CreateProductHandler>() // 1. Starts with the extension method
.AddDecoration<LoggingBehavior<CreateProductCommand, int>>() // 2. Chains a behavior from the returned builder
.AddValidator<CreateProductCommandValidator>(); // 3. Chains a validator from the builder