Class SagaServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Sagas.dll
Service-collection extensions for the Stratara saga runtime.
public static class SagaServiceCollectionExtensions
- Inheritance
-
SagaServiceCollectionExtensions
- Inherited Members
Methods
AddSagaWorker(IServiceCollection, IConfiguration)
Registers the saga runtime services (ISagaManager, ISagaHandler,
ISagaMethodInvoker) and the hosted SagaWorker; binds SagaOptions from
the Sagas configuration section.
public static IServiceCollection AddSagaWorker(this IServiceCollection services, IConfiguration configuration)
Parameters
servicesIServiceCollectionconfigurationIConfiguration
Returns
Examples
Binds SagaOptions from the Sagas section and consumes the event-bundle saga
subscription. Register the sagas separately:
services.AddSagasFromAssemblyContaining<TransferSaga>();
services.AddSagaWorker(configuration);
Remarks
Use together with AddSagasFromAssemblyContaining<T>(IServiceCollection) to discover concrete saga implementations.
AddSagasFromAssemblyContaining<T>(IServiceCollection)
Scans the assembly that contains T for concrete ISaga
implementations and registers each as a scoped ISaga.
public static IServiceCollection AddSagasFromAssemblyContaining<T>(this IServiceCollection services)
Parameters
servicesIServiceCollection
Returns
Type Parameters
TAny type from the assembly to scan.
Examples
Discover and register every ISaga in the saga assembly:
public interface ISagasMarker { }
builder.Services.AddSagasFromAssemblyContaining<ISagasMarker>();