Class ReducerTypeExtensions
Extension methods for working with reducer types.
public static class ReducerTypeExtensions
- Inheritance
-
ReducerTypeExtensions
- Inherited Members
Methods
GetEventSequenceId(Type, string?)
Get the event sequence id for a reducer type.
public static EventSequenceId GetEventSequenceId(this Type type, string? currentEventStoreName = null)
Parameters
typeTypeType to get from.
currentEventStoreNamestringThe name of the event store the reducer is registered in. When provided, event types that belong to the same store will resolve to the event log rather than an inbox sequence.
Returns
- EventSequenceId
The EventSequenceId for the type.
Exceptions
- MultipleEventStoresDefined
Thrown when the reducer handles event types from multiple event stores.
GetHandlerEventTypes(Type)
Get all event types used in the handler method signatures of a reducer type.
public static IEnumerable<Type> GetHandlerEventTypes(this Type type)
Parameters
Returns
- IEnumerable<Type>
All event types found as first parameters in handler methods.
Remarks
A handler method is any non-special public or non-public instance method whose first parameter type carries the EventTypeAttribute. Duplicates are removed so each event type appears at most once.
GetReadModelType(Type)
Get the type of the read model for a reducer.
public static Type GetReadModelType(this Type type)
Parameters
typeTypeReducer type to get for.
Returns
- Type
Type of read model.
GetReducerId(Type)
Get the reducer id for a type.
public static ReducerId GetReducerId(this Type type)
Parameters
Returns
HasExplicitEventSequence(Type)
Get whether a reducer type has an explicit event sequence set.
public static bool HasExplicitEventSequence(this Type type)
Parameters
Returns
IsActive(Type)
Get whether a reducer is active.
public static bool IsActive(this Type type)
Parameters
Returns
- bool
True if it is, false if not.
IsReducerMethod(MethodInfo, Type, IEnumerable<Type>)
Check if a MethodInfo is a reducer method.
public static bool IsReducerMethod(this MethodInfo methodInfo, Type readModelType, IEnumerable<Type> eventTypes)
Parameters
methodInfoMethodInfoMethodInfo to check.
readModelTypeTypeType of read model.
eventTypesIEnumerable<Type>Known event types in the process.
Returns
- bool
True if it is a reducer method, false if not.
Remarks
The following are considered valid reducer method signatures.
Task<TReadModel> {MethodName}(TEvent event, TReadModel? initial, EventContext context) Task<TReadModel> {MethodName}(TEvent event, TReadModel? initial) TReadModel {MethodName}(TEvent event, TReadModel? current, EventContext context) TReadModel {MethodName}(TEvent event, TReadModel? current)