Table of Contents

Class SavvyioOptionsExtensions

Namespace
Savvyio.Domain
Assembly
Savvyio.Domain.dll

Extension methods for the SavvyioOptions class.

public static class SavvyioOptionsExtensions
Inheritance
SavvyioOptionsExtensions

Examples

This example shows how to register a domain-event handler together with the default domain event dispatcher.

using Savvyio;
using Savvyio.Domain;
using Savvyio.Handlers;

namespace ExampleApp;

public sealed class DomainOptionsExtensionsExample
{
    public SavvyioOptions Configure() => new SavvyioOptions().AddDomainEventHandler<AccountOpenedHandler>().AddDomainEventDispatcher();
}

public sealed class AccountOpenedHandler : IDomainEventHandler
{
    public IFireForgetActivator<IDomainEvent> Delegates => HandlerFactory.CreateFireForget<IDomainEvent>(registry => registry.Register<AccountOpenedEvent>(_ => { }));
}

public sealed record AccountOpenedEvent(string AccountId) : Request, IDomainEvent;

Methods

AddDomainEventDispatcher(SavvyioOptions)

Adds a default implementation of the IDomainEventDispatcher interface.

public static SavvyioOptions AddDomainEventDispatcher(this SavvyioOptions options)

Parameters

options SavvyioOptions

The SavvyioOptions to extend.

Returns

SavvyioOptions

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

AddDomainEventHandler<TImplementation>(SavvyioOptions)

Adds an implementation of the IDomainEventHandler interface to HandlerImplementationTypes (if not already registered).

public static SavvyioOptions AddDomainEventHandler<TImplementation>(this SavvyioOptions options) where TImplementation : class, IDomainEventHandler

Parameters

options SavvyioOptions

The SavvyioOptions to extend.

Returns

SavvyioOptions

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

Type Parameters

TImplementation

The type that implements the IDomainEventHandler interface.