Class EventUpcasterServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Abstractions.dll
DI extensions that register IEventUpcaster implementations and the IEventUpcasterPipeline that the event-mapping layer consumes on read.
public static class EventUpcasterServiceCollectionExtensions
- Inheritance
-
EventUpcasterServiceCollectionExtensions
- Inherited Members
Remarks
The default EventUpcasterPipeline is registered lazily on the first
AddEventUpcaster call (and by the event-sourcing mapping wiring), so a host that registers no
upcasters still resolves a transparent pass-through pipeline.
Methods
AddEventUpcaster(IServiceCollection, IEventUpcaster)
Registers an already-constructed IEventUpcaster and ensures the default IEventUpcasterPipeline is present.
public static IServiceCollection AddEventUpcaster(this IServiceCollection services, IEventUpcaster upcaster)
Parameters
servicesIServiceCollectionThe service collection to mutate.
upcasterIEventUpcasterThe upcaster instance to register.
Returns
- IServiceCollection
The same
servicesinstance for chaining.
Examples
services.AddEventUpcaster(new OrderPlacedV1ToV2());
AddEventUpcasterPipeline(IServiceCollection)
Registers the default IEventUpcasterPipeline if no implementation has been
registered yet. Idempotent; called automatically by every AddEventUpcaster overload and by
the event-mapping wiring.
public static IServiceCollection AddEventUpcasterPipeline(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection to mutate.
Returns
- IServiceCollection
The same
servicesinstance for chaining.
Examples
Idempotent, and called for you by every AddEventUpcaster overload — call it directly only
in a host that resolves the pipeline without registering an upcaster:
services.AddEventUpcasterPipeline();
AddEventUpcaster<TUpcaster>(IServiceCollection)
Registers TUpcaster as an IEventUpcaster and ensures the
default IEventUpcasterPipeline is present.
public static IServiceCollection AddEventUpcaster<TUpcaster>(this IServiceCollection services) where TUpcaster : class, IEventUpcaster
Parameters
servicesIServiceCollectionThe service collection to mutate.
Returns
- IServiceCollection
The same
servicesinstance for chaining.
Type Parameters
TUpcasterThe upcaster implementation to register.
Examples
One upcaster per schema hop; the pipeline runs them in registration order:
services.AddEventUpcaster<OrderPlacedV1ToV2>();
services.AddEventUpcaster<OrderPlacedV2ToV3>();