Class EventHandlerMethods

Namespace
Cratis.Chronicle.Reactors
Assembly
Cratis.Chronicle.dll

Extension methods for working with event handler methods.

public static class EventHandlerMethods
Inheritance
EventHandlerMethods
Inherited Members

Methods

HasEventHandlerShape(MethodInfo, IEnumerable<Type>)

Check whether a MethodInfo has the shape of an event handler method — a first parameter that is a known event type, with an optional EventContext or ReactorDelivery as the second parameter — regardless of whether its return type is a supported side-effect return type.

public static bool HasEventHandlerShape(this MethodInfo methodInfo, IEnumerable<Type> eventTypes)

Parameters

methodInfo MethodInfo

MethodInfo to check.

eventTypes IEnumerable<Type>

Known event types in the process.

Returns

bool

True if the method is shaped like an event handler, false if not.

IsEventHandlerMethod(MethodInfo, IEnumerable<Type>)

Check if a MethodInfo is an event handler method.

public static bool IsEventHandlerMethod(this MethodInfo methodInfo, IEnumerable<Type> eventTypes)

Parameters

methodInfo MethodInfo

MethodInfo to check.

eventTypes IEnumerable<Type>

Known event types in the process.

Returns

bool

True if it is, false if not.

Remarks

A handler method is identified solely by its first parameter being a known event type. Any further parameters are treated as dependencies (the EventContext, read models, or services) and are resolved when the method is invoked.

IsEventHandlerMethod(MethodInfo, IEnumerable<Type>, IReactorSideEffectHandlers?)

Checks whether a method is an event handler, including synchronous return types claimed by side-effect handlers.

public static bool IsEventHandlerMethod(this MethodInfo methodInfo, IEnumerable<Type> eventTypes, IReactorSideEffectHandlers? sideEffectHandlers)

Parameters

methodInfo MethodInfo

The method to check.

eventTypes IEnumerable<Type>

Known event types in the process.

sideEffectHandlers IReactorSideEffectHandlers

Handlers that claim synchronous return types.

Returns

bool

True if the method can handle an event; otherwise false.

IsValidSyncSideEffectReturnType(Type, IEnumerable<Type>)

Check whether a Type is a valid synchronous side-effect return type for a reactor handler method. Valid types are: a registered event type, EventForEventSourceId, EventsWithConcurrencyScopes, or any sequence of either a registered event type or EventForEventSourceId.

public static bool IsValidSyncSideEffectReturnType(Type returnType, IEnumerable<Type> eventTypes)

Parameters

returnType Type

The return Type to check.

eventTypes IEnumerable<Type>

Known event types in the process.

Returns

bool

True if it is a valid sync side-effect return type, false if not.

Remarks

Side-effect handlers accept arrays and lists of events as well as enumerable interfaces.

IsValidSyncSideEffectReturnType(Type, IEnumerable<Type>, IReactorSideEffectHandlers?)

Checks a synchronous return type against built-in types and side-effect handlers.

public static bool IsValidSyncSideEffectReturnType(Type returnType, IEnumerable<Type> eventTypes, IReactorSideEffectHandlers? sideEffectHandlers)

Parameters

returnType Type

The return type to check.

eventTypes IEnumerable<Type>

Known event types in the process.

sideEffectHandlers IReactorSideEffectHandlers

Handlers that claim synchronous return types.

Returns

bool

True if the return type can be processed; otherwise false.