Class JsonEventTransformer
- Namespace
- Excalibur.EventSourcing.Upcasting
- Assembly
- Excalibur.EventSourcing.dll
Declarative event upgrader that applies JSON path-based transformations without requiring compile-time event types.
public sealed class JsonEventTransformer : IEventUpgrader
- Inheritance
-
JsonEventTransformer
- Implements
- Inherited Members
Remarks
This transformer parses the serialized event data as a JsonNode, applies the configured transformation rules (rename, remove, add default, move), and returns the modified JSON as the upgraded event.
Use JsonTransformRuleBuilder to construct the transformation rules fluently.
Constructors
JsonEventTransformer(string, int, int, IReadOnlyList<JsonTransformRule>)
Initializes a new instance of the JsonEventTransformer class.
public JsonEventTransformer(string eventType, int fromVersion, int toVersion, IReadOnlyList<JsonTransformRule> rules)
Parameters
eventTypestringThe event type this transformer handles.
fromVersionintThe source version this transformer upgrades from.
toVersionintThe target version this transformer upgrades to.
rulesIReadOnlyList<JsonTransformRule>The transformation rules to apply.
Properties
EventType
Gets the event type this upgrader handles.
public string EventType { get; }
Property Value
- string
The event type this upgrader handles.
FromVersion
Gets the source version this upgrader upgrades from.
public int FromVersion { get; }
Property Value
- int
The source version this upgrader upgrades from.
ToVersion
Gets the target version this upgrader upgrades to.
public int ToVersion { get; }
Property Value
- int
The target version this upgrader upgrades to.
Methods
CanUpgrade(string, int)
Determines whether this upgrader can upgrade the specified event.
public bool CanUpgrade(string eventType, int fromVersion)
Parameters
Returns
- bool
True if this upgrader can handle the upgrade, otherwise false.
Upgrade(object)
Upgrades an event from an older version to a newer version.
public object Upgrade(object oldEvent)
Parameters
oldEventobjectThe old event data.
Returns
- object
The upgraded event.