SavvyioOptions Class
Definition
Specifies options that is related to setting up Savvy I/O services.
public class SavvyioOptions : IParameterObject
- Inheritance
-
SavvyioOptions
- Implements
- Extension Methods
Examples
Configure SavvyioOptions to enable handler and dispatcher discovery, add specific handler and dispatcher registrations, and inspect the resulting counts.
using System;
using Savvyio;
using Savvyio.Dispatchers;
using Savvyio.Handlers;
namespace ExampleApp;
public sealed class SavvyioOptionsExample
{
public void Configure()
{
var options = new SavvyioOptions()
.EnableHandlerDiscovery()
.EnableDispatcherDiscovery()
.EnableHandlerServicesDescriptor()
.AddHandler<IFireForgetHandler<IRequest>, IRequest, CreateOrderHandler>()
.AddDispatcher<IDispatcher, FireForgetDispatcher>();
Console.WriteLine($"Handlers: {options.HandlerImplementationTypes.Count}, Dispatchers: {options.DispatcherImplementationTypes.Count}");
Console.WriteLine($"HandlerDiscovery: {options.AllowHandlerDiscovery}, DispatcherDiscovery: {options.AllowDispatcherDiscovery}");
}
}
public sealed class CreateOrderHandler : IFireForgetHandler<IRequest>
{
public IFireForgetActivator<IRequest> Delegates =>
HandlerFactory.CreateFireForget<IRequest>(r => r.Register<CreateOrderCommand>(_ => { }));
}
public sealed record CreateOrderCommand(string OrderId) : Request;
Constructors
| Name | Description |
|---|---|
| SavvyioOptions() | Initializes a new instance of the SavvyioOptions class. |
Properties
| Name | Description |
|---|---|
| AllowDispatcherDiscovery | Gets a value indicating whether discovery of IDispatcher implementations using assembly scanning is enabled. |
| AllowHandlerDiscovery | Gets a value indicating whether discovery of IHandler implementations using assembly scanning is enabled. |
| DispatcherImplementationTypes | Gets the types implementing an IDispatcher service. |
| DispatcherServiceTypes | Gets the types associated with an IDispatcher service. |
| HandlerImplementationTypes | Gets the types implementing an IHandler service. |
| HandlerServiceTypes | Gets the types associated with an IHandler service. |
| IncludeHandlerServicesDescriptor | Gets a value indicating whether the HandlerServicesDescriptor is enabled. |
Methods
| Name | Description |
|---|---|
| AddDispatcher(Type, Type) | Adds a dispatcher of type IDispatcher to DispatcherServiceTypes (if not already registered) and DispatcherImplementationTypes (if not already registered). |
| AddDispatcher<TDispatcher, TImplementation>() | Adds a dispatcher of type |
| AddHandler(Type, Type) | Adds a dispatcher of type IHandler to HandlerServiceTypes (if not already registered) and HandlerImplementationTypes (if not already registered). |
| AddHandler<THandler, TRequest, TImplementation>() | Adds a handler of type |
| EnableDispatcherDiscovery(bool) | Enables discovery of dispatchers implementing the IDispatcher interface using assembly scanning. |
| EnableHandlerDiscovery(bool) | Enables discovery of handlers implementing the IHandler interface using assembly scanning. |
| EnableHandlerServicesDescriptor(bool) | Enables the inclusion of the HandlerServicesDescriptor that provides an overview of all handlers presented in a detailed and developer friendly way. |
| IsValid<T>(Type, Type) | Determines if a given pair of types are a valid as a dependency. |