Table of Contents

SavvyioOptionsExtensions Class

Definition

Namespace
Savvyio.Domain
Assemblies
Savvyio.Domain.dll
Source
src/Savvyio.Domain/SavvyioOptionsExtensions.cs

Extension methods for the SavvyioOptions class.

public static class SavvyioOptionsExtensions
Inheritance
object
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

Name Description
AddDomainEventDispatcher(SavvyioOptions)

Adds a default implementation of the IDomainEventDispatcher interface.

AddDomainEventHandler<TImplementation>(SavvyioOptions)

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