Class MutationHistory
Represents the full mutation history of a specific state object.
Inherited Members
Namespace: ModularityKit.Mutator.Abstractions.History
Assembly: ModularityKit.Mutator.dll
Syntax
public sealed class MutationHistory
Remarks
MutationHistory stores a chronological sequence of MutationHistoryEntry entries. It allows replaying state changes, querying timelines for specific paths, and computing statistics. This is typically used in combination with IMutationHistoryStore to persist and retrieve histories.
Properties
| Edit this page View SourceEntries
Chronological list of mutation entries.
Declaration
public IReadOnlyList<MutationHistoryEntry> Entries { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<MutationHistoryEntry> |
FirstMutationAt
Timestamp of the first mutation in the history.
Declaration
public DateTimeOffset? FirstMutationAt { get; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset? |
LastMutationAt
Timestamp of the last mutation in the history.
Declaration
public DateTimeOffset? LastMutationAt { get; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset? |
StateId
Unique identifier of the state object.
Declaration
public string StateId { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
StateType
Type of the state object.
Declaration
public string StateType { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
TotalMutations
Total number of mutations recorded.
Declaration
public int TotalMutations { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceGetStatistics()
Computes summary statistics of the mutation history.
Declaration
public HistoryStatistics GetStatistics()
Returns
| Type | Description |
|---|---|
| HistoryStatistics | A HistoryStatistics instance containing totals, averages, and mutation distribution. |
GetTimelineForPath(string)
Retrieves a timeline of changes for a specific property path.
Declaration
public IEnumerable<StateChangeTimeline> GetTimelineForPath(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The property path (e.g., "Email" or "Address.City"). |
Returns
| Type | Description |
|---|---|
| IEnumerable<StateChangeTimeline> | A chronological sequence of StateChangeTimeline entries for that path. |
ReplayUntil<TState>(TState, DateTimeOffset, Func<TState, ChangeSet, TState>)
Replays the mutation history up to a specific timestamp.
Declaration
public TState ReplayUntil<TState>(TState initialState, DateTimeOffset timestamp, Func<TState, ChangeSet, TState> applyChanges)
Parameters
| Type | Name | Description |
|---|---|---|
| TState | initialState | The initial state before any mutations. |
| DateTimeOffset | timestamp | Replay mutations only up to this timestamp (inclusive). |
| Func<TState, ChangeSet, TState> | applyChanges | Function that applies a ChangeSet to a state instance. |
Returns
| Type | Description |
|---|---|
| TState | The reconstructed state as of the given timestamp. |
Type Parameters
| Name | Description |
|---|---|
| TState | Type of the state object. |
Replay<TState>(TState, Func<TState, ChangeSet, TState>)
Replays the full mutation history to reconstruct the current state.
Declaration
public TState Replay<TState>(TState initialState, Func<TState, ChangeSet, TState> applyChanges)
Parameters
| Type | Name | Description |
|---|---|---|
| TState | initialState | The initial state before any mutations. |
| Func<TState, ChangeSet, TState> | applyChanges | Function that applies a ChangeSet to a state instance. |
Returns
| Type | Description |
|---|---|
| TState | The reconstructed state after applying all mutations. |
Type Parameters
| Name | Description |
|---|---|
| TState | Type of the state object. |