Table of Contents

Class SavvyioOptionsExtensions

Namespace
Savvyio
Assembly
Savvyio.Core.dll

Extension methods for the SavvyioOptions class.

public static class SavvyioOptionsExtensions
Inheritance
SavvyioOptionsExtensions

Examples

This example shows how to scan an assembly for handler and dispatcher contracts so Savvy I/O can register them automatically.

using Savvyio;
using Savvyio.Commands;
using Savvyio.Dispatchers;
using Savvyio.Handlers;

namespace ExampleApp;

public sealed class SavvyioOptionsExtensionsExample
{
    public SavvyioOptions Configure() => new SavvyioOptions().AddHandlers(typeof(CreateOrderHandler).Assembly).AddDispatchers(typeof(CheckoutDispatcher).Assembly);
}

public interface ICheckoutDispatcher : IDispatcher { }
public sealed class CheckoutDispatcher : ICheckoutDispatcher { }
public sealed class CreateOrderHandler : ICommandHandler
{
    public IFireForgetActivator<ICommand> Delegates => HandlerFactory.CreateFireForget<ICommand>(registry => registry.Register<CreateOrderCommand>(_ => { }));
}
public sealed record CreateOrderCommand(string OrderId) : Request, ICommand;

Methods

AddDispatchers(SavvyioOptions, params Assembly[])

Adds handlers of type IDispatcher from the specified assemblies to the extended options.

public static SavvyioOptions AddDispatchers(this SavvyioOptions options, params Assembly[] assemblies)

Parameters

options SavvyioOptions

The SavvyioOptions to extend.

assemblies Assembly[]

The assemblies to scan for IDispatcher implementations.

Returns

SavvyioOptions

A reference to options so that additional configuration calls can be chained.

Exceptions

ArgumentNullException

assemblies cannot be null.

AddHandlers(SavvyioOptions, params Assembly[])

Adds handlers of type IHandler from the specified assemblies to the extended options.

public static SavvyioOptions AddHandlers(this SavvyioOptions options, params Assembly[] assemblies)

Parameters

options SavvyioOptions

The SavvyioOptions to extend.

assemblies Assembly[]

The assemblies to scan for IHandler implementations.

Returns

SavvyioOptions

A reference to options so that additional configuration calls can be chained.

Exceptions

ArgumentNullException

assemblies cannot be null.