Table of Contents

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

mode CompositeSnapshotStrategy.CompositeMode

The composite mode.

strategies ISnapshotStrategy[]

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

strategy ISnapshotStrategy

The strategy to add.

Exceptions

ArgumentNullException

Thrown when strategy is null.

RemoveStrategy(ISnapshotStrategy)

Removes a strategy from the composite.

public bool RemoveStrategy(ISnapshotStrategy strategy)

Parameters

strategy ISnapshotStrategy

The 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

aggregate IAggregateRoot

The aggregate to check.

Returns

bool

True if a snapshot should be created, otherwise false.