Table of Contents

Class ScenarioHistory

Namespace
Virtufin.Base
Assembly
Virtufin.Base.dll

Concrete IScenarioHistory backed by an in-memory list of scenarios. New scenarios are emitted through a hot System.Reactive.Subjects.Subject<T> with no replay buffer — late subscribers see only future emissions.

public sealed class ScenarioHistory : IScenarioHistory, IEnumerable<IScenario>, IEnumerable, IDisposable
Inheritance
ScenarioHistory
Implements
Inherited Members

Examples

var history = new ScenarioHistory();
history.Append(new Scenario(TimeStamp.New(2024,1,1), State.Empty));
using var sub = history.NewScenarios.Subscribe(s => Console.WriteLine(s.TimeStamp));
history.Append(new Scenario(TimeStamp.New(2024,1,2), State.Empty)); // printed

Constructors

ScenarioHistory()

Construct an empty history.

public ScenarioHistory()

ScenarioHistory(IEnumerable<Scenario>)

Construct a history pre-populated with scenarios.

public ScenarioHistory(IEnumerable<Scenario> scenarios)

Parameters

scenarios IEnumerable<Scenario>

Initial scenarios.

Properties

Iter

Iterate scenarios in insertion order.

public IEnumerable<IScenario> Iter { get; }

Property Value

IEnumerable<IScenario>

LastScenario

The most recently appended scenario.

public IScenario LastScenario { get; }

Property Value

IScenario

NewScenarios

Hot observable of newly-appended scenarios. Late subscribers see no history. Use the existing Subject<T> Unsubscribe pattern for proper disposal (see AGENTS.md).

public IObservable<IScenario> NewScenarios { get; }

Property Value

IObservable<IScenario>

Methods

Append(Scenario)

Append a concrete Scenario(ITimeStamp) to the history.

public void Append(Scenario scenario)

Parameters

scenario Scenario

Append(IScenario)

Append a scenario to the history. Emits on NewScenarios.

public void Append(IScenario scenario)

Parameters

scenario IScenario

Scenario to append.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<IScenario> GetEnumerator()

Returns

IEnumerator<IScenario>

An enumerator that can be used to iterate through the collection.

Scenario(ITimeStamp)

Look up the first scenario matching timeStamp. Returns null if no scenario matches.

public IScenario? Scenario(ITimeStamp timeStamp)

Parameters

timeStamp ITimeStamp

Time-point to search for.

Returns

IScenario