Table of Contents

Class SnapshotRepository

Namespace
Shift.Common.Timeline.Snapshots
Assembly
Shift.Common.dll

Saves and gets snapshots to and from a snapshot store.

public class SnapshotRepository : IChangeRepository
Inheritance
SnapshotRepository
Implements
Inherited Members
Extension Methods

Constructors

SnapshotRepository(IChangeStore, IChangeRepository, ISnapshotStore, ISnapshotStrategy)

Constructs a new SnapshotRepository instance.

public SnapshotRepository(IChangeStore changeStore, IChangeRepository changeRepository, ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy)

Parameters

changeStore IChangeStore

Store where changes are persisted

changeRepository IChangeRepository

Repository to get aggregates from the change store

snapshotStore ISnapshotStore

Store where snapshots are persisted

snapshotStrategy ISnapshotStrategy

Strategy used to determine when to take a snapshot

Methods

Box<T>(T)

Copies an aggregate to offline storage and removes it from online logs.

public void Box<T>(T aggregate) where T : AggregateRoot

Parameters

aggregate T

Type Parameters

T

Exists<T>(Guid)

Returns true if an aggregate exists.

public bool Exists<T>(Guid aggregate)

Parameters

aggregate Guid

Returns

bool

Type Parameters

T

GetClone<T>(Guid, int?)

public T GetClone<T>(Guid aggregateId, int? expectedVersion = -1) where T : AggregateRoot

Parameters

aggregateId Guid
expectedVersion int?

Returns

T

Type Parameters

T

GetPrevAndCurrentStates(Guid, int)

public (AggregateState prev, AggregateState current) GetPrevAndCurrentStates(Guid aggregateId, int version)

Parameters

aggregateId Guid
version int

Returns

(AggregateState prev, AggregateState current)

GetStatesAndChanges(Guid)

public IChange[] GetStatesAndChanges(Guid aggregateId)

Parameters

aggregateId Guid

Returns

IChange[]

Get<T>(Guid, int?)

Gets the aggregate.

public T Get<T>(Guid aggregateId, int? version = -1) where T : AggregateRoot

Parameters

aggregateId Guid
version int?

Returns

T

Type Parameters

T

LockAndRun<T>(Guid, Action<T>)

public void LockAndRun<T>(Guid aggregateId, Action<T> action) where T : AggregateRoot

Parameters

aggregateId Guid
action Action<T>

Type Parameters

T

Peek<T>(Guid, int)

Returns a specific aggregate as at a specific version.

public T Peek<T>(Guid _, int __) where T : AggregateRoot

Parameters

_ Guid
__ int

Returns

T

Type Parameters

T

Ping()

Checks for expired aggregates. Automatically boxes all aggregates for which the timer is now elapsed.

public void Ping()

Save<T>(T, int?)

Saves the aggregate. Takes a snapshot if needed.

public IChange[] Save<T>(T aggregate, int? version = null) where T : AggregateRoot

Parameters

aggregate T
version int?

Returns

IChange[]

Type Parameters

T

Unbox<T>(Guid)

Retrieves an aggregate from offline storage and returns only its most recent state.

public T Unbox<T>(Guid aggregateId) where T : AggregateRoot

Parameters

aggregateId Guid

Returns

T

Type Parameters

T