Class ProjectionServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Projections.dll
Dependency-injection extension methods that wire the Stratara projection runtime (manager, handler, method invoker, worker, replay worker) and discover IProjection implementations by assembly scan.
public static class ProjectionServiceCollectionExtensions
- Inheritance
-
ProjectionServiceCollectionExtensions
- Inherited Members
Methods
AddProjectionWorker(IServiceCollection, IConfiguration)
Registers the projection runtime — Stratara.Projections.Services.ProjectionManager, Stratara.Projections.Services.ProjectionHandler, Stratara.Projections.Services.ProjectionMethodInvoker, Stratara.Projections.Services.ProjectionWorker, and Stratara.Projections.Services.ProjectionReplayWorker — and binds ProjectionOptions from configuration.
public static IServiceCollection AddProjectionWorker(this IServiceCollection services, IConfiguration configuration)
Parameters
servicesIServiceCollectionThe service collection to register against.
configurationIConfigurationThe configuration root used to bind ProjectionOptions.
Returns
- IServiceCollection
The service collection for chaining.
Examples
Binds ProjectionOptions from the Projections section. Register the projections
themselves separately — this call wires the runtime, not your read models:
services.AddProjectionsFromAssemblyContaining<AccountBalanceProjection>();
services.AddProjectionWorker(configuration);
AddProjectionsFromAssemblyContaining<T>(IServiceCollection)
Scans the assembly containing T and registers every concrete
IProjection implementation it finds as a scoped service.
public static IServiceCollection AddProjectionsFromAssemblyContaining<T>(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection to register against.
Returns
- IServiceCollection
The service collection for chaining.
Type Parameters
TA marker type that lives in the assembly to scan (typically a per-project
IMarkerinterface).
Examples
Discover and register every IProjection in the projections assembly:
public interface IProjectionsMarker { }
builder.Services.AddProjectionsFromAssemblyContaining<IProjectionsMarker>();