Class SetFromContextAttribute<TEvent>
- Assembly
- Cratis.Chronicle.dll
Attribute used to indicate that a property value should be set from an event context property.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Parameter, AllowMultiple = true)]
public sealed class SetFromContextAttribute<TEvent> : Attribute, IProjectionAnnotation, ISetFromContextAttribute, IEventBoundAttribute
Type Parameters
TEventThe type of event to set from.
- Inheritance
-
SetFromContextAttribute<TEvent>
- Implements
- Inherited Members
- Extension Methods
Remarks
This only ever reads EventContext, never TEvent's own payload - but it
still subscribes the projection to TEvent. Once subscribed, AutoMap becomes eligible
for every one of TEvent's payload properties against any same-named property on the
model, regardless of which attribute caused the subscription. If TEvent is not
otherwise referenced, a same-named payload property can silently overwrite an unrelated, explicitly-sourced
model property with no attribute anywhere near it that looks responsible. Fence an affected property with
NoAutoMapAttribute when this is not wanted.
Constructors
SetFromContextAttribute(string?)
Attribute used to indicate that a property value should be set from an event context property.
public SetFromContextAttribute(string? contextPropertyName = null)
Parameters
contextPropertyNamestringOptional name of the property on the event context. If not specified, uses the model property name.
Remarks
This only ever reads EventContext, never TEvent's own payload - but it
still subscribes the projection to TEvent. Once subscribed, AutoMap becomes eligible
for every one of TEvent's payload properties against any same-named property on the
model, regardless of which attribute caused the subscription. If TEvent is not
otherwise referenced, a same-named payload property can silently overwrite an unrelated, explicitly-sourced
model property with no attribute anywhere near it that looks responsible. Fence an affected property with
NoAutoMapAttribute when this is not wanted.
Properties
ContextPropertyName
Gets the name of the property on the event context.
public string? ContextPropertyName { get; }
Property Value
EventType
Gets the type of event this attribute is bound to.
public Type EventType { get; }