Class EventRelevance
- Namespace
- Stratara.Abstractions.EventSourcing
- Assembly
- Stratara.Abstractions.dll
Which recorded events a reader has a use for, so the event mapper can leave every other event unread: not resolved against the trusted types and not decrypted.
public sealed class EventRelevance
- Inheritance
-
EventRelevance
- Inherited Members
- Extension Methods
Remarks
A projection or a stateless saga is dispatched events by their exact type, so its host's relevance is ForTypes(IEnumerable<Type>) of the types its handlers take. An event whose type, after upcasting, resolves to one of them is mapped; one that resolves to another type is skipped. An event whose type does not resolve is skipped too — unless its name, without namespace or assembly, is the name of a relevant type, in which case it is mapped and fails as an unregistered type does, so a handled type moved without an upcaster is reported rather than lost.
A stateful saga process decides from the event itself whether it handles it, so its reader uses AnyResolvableWith(IEnumerable<Type>): every event whose type resolves is mapped, and one whose type does not is skipped — unless it carries the name of a type the process declares a handler for.
Properties
AnyResolvable
Every event whose type resolves is relevant; none whose type does not.
public static EventRelevance AnyResolvable { get; }
Property Value
IsAnyResolvable
Whether this relevance takes every resolvable type rather than a set of them.
public bool IsAnyResolvable { get; }
Property Value
Methods
AnyResolvableWith(IEnumerable<Type>)
Every event whose type resolves is relevant; one whose type does not is relevant only when it carries the name of
one of declaredTypes, so that it fails as an unregistered type does.
public static EventRelevance AnyResolvableWith(IEnumerable<Type> declaredTypes)
Parameters
declaredTypesIEnumerable<Type>The types a reader declares handlers for, beside deciding the rest at run time.
Returns
- EventRelevance
The relevance.
Exceptions
- ArgumentNullException
declaredTypesis null.- ArgumentException
declaredTypescontains null.
ForTypes(IEnumerable<Type>)
The events of exactly types are relevant.
public static EventRelevance ForTypes(IEnumerable<Type> types)
Parameters
typesIEnumerable<Type>The event payload types a reader's handlers take.
Returns
- EventRelevance
The relevance of those types.
Exceptions
- ArgumentNullException
typesis null.- ArgumentException
typescontains null.
Includes(Type)
Whether an event of eventType is relevant.
public bool Includes(Type eventType)
Parameters
eventTypeTypeThe event's payload type, as resolved after upcasting.
Returns
Exceptions
- ArgumentNullException
eventTypeis null.
MayName(string)
Whether an event whose type does not resolve could still be a relevant one: its type name, without namespace or assembly, is the name of a relevant type.
public bool MayName(string typeName)
Parameters
typeNamestringThe simple type name, without namespace, declaring type or assembly.
Returns
Exceptions
- ArgumentNullException
typeNameis null.