Table of Contents

Class StateValidator

Namespace
StockSharp.Messages
Assembly
StockSharp.Messages.dll

Unified state transition validator for all state enums.

public static class StateValidator
Inheritance
StateValidator
Inherited Members

Remarks

Provides centralized validation of state transitions with configurable behavior:

  • Returns bool for simple validation
  • Logs warnings for invalid transitions
  • Throws exceptions when required

Methods

IsActive(ChannelStates)

Determines if the ChannelStates is an active (working) state.

public static bool IsActive(ChannelStates state)

Parameters

state ChannelStates

State to check.

Returns

bool

true if state is active; otherwise false.

IsActive(OrderStates)

Determines if the OrderStates is an active (working) state.

public static bool IsActive(OrderStates state)

Parameters

state OrderStates

State to check.

Returns

bool

true if state is active; otherwise false.

IsActive(SessionStates)

Determines if the SessionStates is an active (working) state.

public static bool IsActive(SessionStates state)

Parameters

state SessionStates

State to check.

Returns

bool

true if state is active; otherwise false.

IsActive(SubscriptionStates)

Determines if the SubscriptionStates is an active (working) state.

public static bool IsActive(SubscriptionStates state)

Parameters

state SubscriptionStates

State to check.

Returns

bool

true if state is active; otherwise false.

IsStopped(ChannelStates)

Determines if the ChannelStates is a stopped state.

public static bool IsStopped(ChannelStates state)

Parameters

state ChannelStates

State to check.

Returns

bool

true if state is stopped; otherwise false.

IsTerminal(OrderStates)

Determines if the OrderStates is a terminal (final) state.

public static bool IsTerminal(OrderStates state)

Parameters

state OrderStates

State to check.

Returns

bool

true if state is terminal; otherwise false.

IsTerminal(SessionStates)

Determines if the SessionStates is a terminal (final) state.

public static bool IsTerminal(SessionStates state)

Parameters

state SessionStates

State to check.

Returns

bool

true if state is terminal; otherwise false.

IsTerminal(SubscriptionStates)

Determines if the SubscriptionStates is a terminal (final) state.

public static bool IsTerminal(SubscriptionStates state)

Parameters

state SubscriptionStates

State to check.

Returns

bool

true if state is terminal; otherwise false.

IsValid(ChannelStates, ChannelStates)

Check if transition from one ChannelStates to another is valid.

public static bool IsValid(ChannelStates from, ChannelStates to)

Parameters

from ChannelStates

Current state.

to ChannelStates

New state.

Returns

bool

true if transition is valid; otherwise false.

IsValid(OrderStates, OrderStates)

Check if transition from one OrderStates to another is valid.

public static bool IsValid(OrderStates from, OrderStates to)

Parameters

from OrderStates

Current state.

to OrderStates

New state.

Returns

bool

true if transition is valid; otherwise false.

IsValid(SessionStates, SessionStates)

Check if transition from one SessionStates to another is valid.

public static bool IsValid(SessionStates from, SessionStates to)

Parameters

from SessionStates

Current state.

to SessionStates

New state.

Returns

bool

true if transition is valid; otherwise false.

IsValid(SubscriptionStates, SubscriptionStates)

Check if transition from one SubscriptionStates to another is valid.

public static bool IsValid(SubscriptionStates from, SubscriptionStates to)

Parameters

from SubscriptionStates

Current state.

to SubscriptionStates

New state.

Returns

bool

true if transition is valid; otherwise false.

Validate(ChannelStates, ChannelStates, object, ILogReceiver, bool)

Validate ChannelStates transition with logging and optional exception.

public static bool Validate(ChannelStates from, ChannelStates to, object context, ILogReceiver logs, bool throwOnInvalid = false)

Parameters

from ChannelStates

Current state.

to ChannelStates

New state.

context object

Context for error message.

logs ILogReceiver

Log receiver for warnings.

throwOnInvalid bool

If true, throws InvalidOperationException on invalid transition.

Returns

bool

true if transition is valid; otherwise false.

Validate(SessionStates, SessionStates, object, ILogReceiver, bool)

Validate SessionStates transition with logging and optional exception.

public static bool Validate(SessionStates from, SessionStates to, object context, ILogReceiver logs, bool throwOnInvalid = false)

Parameters

from SessionStates

Current state.

to SessionStates

New state.

context object

Context for error message.

logs ILogReceiver

Log receiver for warnings.

throwOnInvalid bool

If true, throws InvalidOperationException on invalid transition.

Returns

bool

true if transition is valid; otherwise false.

Validate(SubscriptionStates, SubscriptionStates, object, ILogReceiver, bool)

Validate SubscriptionStates transition with logging and optional exception.

public static bool Validate(SubscriptionStates from, SubscriptionStates to, object context, ILogReceiver logs, bool throwOnInvalid = false)

Parameters

from SubscriptionStates

Current state.

to SubscriptionStates

New state.

context object

Context for error message (e.g., subscription id).

logs ILogReceiver

Log receiver for warnings.

throwOnInvalid bool

If true, throws InvalidOperationException on invalid transition.

Returns

bool

true if transition is valid; otherwise false.

Validate(OrderStates?, OrderStates, object, ILogReceiver, bool)

Validate OrderStates transition with logging and optional exception.

public static bool Validate(OrderStates? from, OrderStates to, object context, ILogReceiver logs, bool throwOnInvalid = false)

Parameters

from OrderStates?

Current state (null means initial state).

to OrderStates

New state.

context object

Context for error message (e.g., transaction id).

logs ILogReceiver

Log receiver for warnings.

throwOnInvalid bool

If true, throws InvalidOperationException on invalid transition.

Returns

bool

true if transition is valid; otherwise false.