Skip to main content
Table of Contents

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

services IServiceCollection
configuration IConfiguration

Returns

IServiceCollection

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

services IServiceCollection

Returns

IServiceCollection

Type Parameters

T

Any type from the assembly to scan.

Examples

Discover and register every ISaga in the saga assembly:

public interface ISagasMarker { }

builder.Services.AddSagasFromAssemblyContaining<ISagasMarker>();