Class EventValueMapBuilder<TUpgrade, TPrevious>
- Namespace
- Cratis.Chronicle.Events.Migrations
- Assembly
- Cratis.Chronicle.dll
Represents an implementation of IEventValueMapBuilder<TUpgrade, TPrevious>.
public class EventValueMapBuilder<TUpgrade, TPrevious> : IEventValueMapBuilder<TUpgrade, TPrevious>
Type Parameters
TUpgradeThe upgraded (newer generation) event type.
TPreviousThe previous (older generation) event type.
- Inheritance
-
EventValueMapBuilder<TUpgrade, TPrevious>
- Implements
-
IEventValueMapBuilder<TUpgrade, TPrevious>
- Inherited Members
- Extension Methods
Constructors
EventValueMapBuilder()
public EventValueMapBuilder()
Properties
HasMaps
Gets whether any value map has been declared.
public bool HasMaps { get; }
Property Value
Methods
ApplyDowncast(IEventMigrationPropertyBuilder)
Apply every declared map to the downcast of the migration, translating upgraded values back into previous ones.
public void ApplyDowncast(IEventMigrationPropertyBuilder builder)
Parameters
builderIEventMigrationPropertyBuilderThe IEventMigrationPropertyBuilder to apply to.
ApplyUpcast(IEventMigrationPropertyBuilder)
Apply every declared map to the upcast of the migration, translating previous values into upgraded ones.
public void ApplyUpcast(IEventMigrationPropertyBuilder builder)
Parameters
builderIEventMigrationPropertyBuilderThe IEventMigrationPropertyBuilder to apply to.
For<TUpgradeProperty, TPreviousProperty>(Expression<Func<TUpgrade, TUpgradeProperty>>, Expression<Func<TPrevious, TPreviousProperty>>, Action<IValueMapBuilder<TPreviousProperty, TUpgradeProperty>>)
Declare the value map for a property, from how the previous generation expressed it to how the upgraded generation does.
public IEventValueMapBuilder<TUpgrade, TPrevious> For<TUpgradeProperty, TPreviousProperty>(Expression<Func<TUpgrade, TUpgradeProperty>> upgradeProperty, Expression<Func<TPrevious, TPreviousProperty>> previousProperty, Action<IValueMapBuilder<TPreviousProperty, TUpgradeProperty>> map)
Parameters
upgradePropertyExpression<Func<TUpgrade, TUpgradeProperty>>Expression selecting the property on the upgraded generation.
previousPropertyExpression<Func<TPrevious, TPreviousProperty>>Expression selecting the property on the previous generation.
mapAction<IValueMapBuilder<TPreviousProperty, TUpgradeProperty>>Action declaring which value becomes which.
Returns
- IEventValueMapBuilder<TUpgrade, TPrevious>
The builder for continued configuration.
Type Parameters
TUpgradePropertyThe type of the property on the upgraded generation.
TPreviousPropertyThe type of the property on the previous generation.
Remarks
The two properties do not have to share a name - the map carries the value across from one to the other, so it also covers a rename of the property it maps.