Class SavvyioOptionsExtensions
- Namespace
- Savvyio.EventDriven
- Assembly
- Savvyio.EventDriven.dll
Extension methods for the SavvyioOptions class.
public static class SavvyioOptionsExtensions
- Inheritance
-
SavvyioOptionsExtensions
Examples
This example shows how to register an integration-event handler together with the default integration event dispatcher.
using Savvyio;
using Savvyio.EventDriven;
using Savvyio.Handlers;
namespace ExampleApp;
public sealed class EventDrivenOptionsExtensionsExample
{
public SavvyioOptions Configure() => new SavvyioOptions().AddIntegrationEventHandler<MemberCreatedHandler>().AddIntegrationEventDispatcher();
}
public sealed class MemberCreatedHandler : IIntegrationEventHandler
{
public IFireForgetActivator<IIntegrationEvent> Delegates => HandlerFactory.CreateFireForget<IIntegrationEvent>(registry => registry.Register<MemberCreatedEvent>(_ => { }));
}
public sealed record MemberCreatedEvent(string MemberId) : Request, IIntegrationEvent;
Methods
AddIntegrationEventDispatcher(SavvyioOptions)
Adds a default implementation of the IIntegrationEventDispatcher interface.
public static SavvyioOptions AddIntegrationEventDispatcher(this SavvyioOptions options)
Parameters
optionsSavvyioOptionsThe SavvyioOptions to extend.
Returns
- SavvyioOptions
A reference to
optionsso that additional configuration calls can be chained.
AddIntegrationEventHandler<TImplementation>(SavvyioOptions)
Adds an implementation of the IIntegrationEventHandler interface to HandlerImplementationTypes (if not already registered).
public static SavvyioOptions AddIntegrationEventHandler<TImplementation>(this SavvyioOptions options) where TImplementation : class, IIntegrationEventHandler
Parameters
optionsSavvyioOptionsThe SavvyioOptions to extend.
Returns
- SavvyioOptions
A reference to
optionsso that additional configuration calls can be chained.
Type Parameters
TImplementationThe type that implements the IIntegrationEventHandler interface.