Table of Contents

Class AggregateRoot

Namespace
Shift.Common.Timeline.Changes
Assembly
Shift.Common.dll

Implements the base class for all aggregate roots. An aggregate forms a tree or graph of object relations. The aggregate root is the top-level container, which speaks for the whole and may delegates down to the rest. It is important because it is the one that the rest of the world communicates with.

public abstract class AggregateRoot
Inheritance
AggregateRoot
Derived
Inherited Members
Extension Methods

Constructors

AggregateRoot()

protected AggregateRoot()

Properties

AggregateIdentifier

Uniquely identifies the aggregate.

public Guid AggregateIdentifier { get; set; }

Property Value

Guid

AggregateVersion

Current version of the aggregate.

public int AggregateVersion { get; set; }

Property Value

int

RootAggregateIdentifier

Uniquely identifies the aggregate.

public Guid RootAggregateIdentifier { get; set; }

Property Value

Guid

State

Represents the state (i.e. data/packet) for the aggregate.

public AggregateState State { get; set; }

Property Value

AggregateState

Methods

Apply(IChange)

Applies a change to the aggregate state AND appends the event to the history of uncommited changes.

public void Apply(IChange change)

Parameters

change IChange

ApplyChange(IChange)

Applies a change to the aggregate state. This method is called internally when rehydrating an aggregate, and you can override this when custom handling is needed.

protected virtual void ApplyChange(IChange change)

Parameters

change IChange

CreateState()

Every aggregate must override this method to create the object that holds its current state.

public abstract AggregateState CreateState()

Returns

AggregateState

FlushUncommittedChanges()

Returns all uncommitted changes and clears them from the aggregate.

public IChange[] FlushUncommittedChanges()

Returns

IChange[]

GetUncommittedChanges()

Returns all uncommitted changes.

public IChange[] GetUncommittedChanges()

Returns

IChange[]

Identify(Guid, Guid)

Assigns a specific organization and user identity to every uncomitted change.

public void Identify(Guid organization, Guid user)

Parameters

organization Guid
user Guid

LockAndRun(Command, Action)

public void LockAndRun(Command context, Action action)

Parameters

context Command
action Action

LockAndRun(Action)

public void LockAndRun(Action action)

Parameters

action Action

Rehydrate(IEnumerable<IChange>)

Loads an aggregate from a stream of events.

public void Rehydrate(IEnumerable<IChange> history)

Parameters

history IEnumerable<IChange>