Class CompositeSnapshotStrategy
- Namespace
- Excalibur.EventSourcing.Snapshots
- Assembly
- Excalibur.EventSourcing.dll
Composite snapshot strategy that combines multiple strategies.
public sealed class CompositeSnapshotStrategy : ISnapshotStrategy
- Inheritance
-
CompositeSnapshotStrategy
- Implements
- Inherited Members
Remarks
Allows combining multiple snapshot strategies using either Any (OR) or All (AND) logic. Useful for complex snapshotting rules that depend on multiple conditions.
Constructors
CompositeSnapshotStrategy(CompositeMode, params ISnapshotStrategy[])
Initializes a new instance of the CompositeSnapshotStrategy class.
public CompositeSnapshotStrategy(CompositeSnapshotStrategy.CompositeMode mode, params ISnapshotStrategy[] strategies)
Parameters
modeCompositeSnapshotStrategy.CompositeModeThe composite mode.
strategiesISnapshotStrategy[]The strategies to combine.
Exceptions
- ArgumentException
Thrown when no strategies are provided.
Properties
StrategyCount
Gets the number of strategies in the composite.
public int StrategyCount { get; }
Property Value
- int
The number of strategies in the composite.
Methods
AddStrategy(ISnapshotStrategy)
Adds a strategy to the composite.
public void AddStrategy(ISnapshotStrategy strategy)
Parameters
strategyISnapshotStrategyThe strategy to add.
Exceptions
- ArgumentNullException
Thrown when strategy is null.
RemoveStrategy(ISnapshotStrategy)
Removes a strategy from the composite.
public bool RemoveStrategy(ISnapshotStrategy strategy)
Parameters
strategyISnapshotStrategyThe strategy to remove.
Returns
- bool
True if the strategy was removed, otherwise false.
ShouldCreateSnapshot(IAggregateRoot)
Determines whether a snapshot should be created for the aggregate.
[RequiresUnreferencedCode("Snapshot strategy evaluation may require types that cannot be statically analyzed. Consider using source generation.")]
[RequiresDynamicCode("Snapshot strategy evaluation may require dynamic code generation which is not compatible with AOT compilation.")]
public bool ShouldCreateSnapshot(IAggregateRoot aggregate)
Parameters
aggregateIAggregateRootThe aggregate to check.
Returns
- bool
True if a snapshot should be created, otherwise false.