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
stateChannelStatesState to check.
Returns
- bool
trueif state is active; otherwisefalse.
IsActive(OrderStates)
Determines if the OrderStates is an active (working) state.
public static bool IsActive(OrderStates state)
Parameters
stateOrderStatesState to check.
Returns
- bool
trueif state is active; otherwisefalse.
IsActive(SessionStates)
Determines if the SessionStates is an active (working) state.
public static bool IsActive(SessionStates state)
Parameters
stateSessionStatesState to check.
Returns
- bool
trueif state is active; otherwisefalse.
IsActive(SubscriptionStates)
Determines if the SubscriptionStates is an active (working) state.
public static bool IsActive(SubscriptionStates state)
Parameters
stateSubscriptionStatesState to check.
Returns
- bool
trueif state is active; otherwisefalse.
IsStopped(ChannelStates)
Determines if the ChannelStates is a stopped state.
public static bool IsStopped(ChannelStates state)
Parameters
stateChannelStatesState to check.
Returns
- bool
trueif state is stopped; otherwisefalse.
IsTerminal(OrderStates)
Determines if the OrderStates is a terminal (final) state.
public static bool IsTerminal(OrderStates state)
Parameters
stateOrderStatesState to check.
Returns
- bool
trueif state is terminal; otherwisefalse.
IsTerminal(SessionStates)
Determines if the SessionStates is a terminal (final) state.
public static bool IsTerminal(SessionStates state)
Parameters
stateSessionStatesState to check.
Returns
- bool
trueif state is terminal; otherwisefalse.
IsTerminal(SubscriptionStates)
Determines if the SubscriptionStates is a terminal (final) state.
public static bool IsTerminal(SubscriptionStates state)
Parameters
stateSubscriptionStatesState to check.
Returns
- bool
trueif state is terminal; otherwisefalse.
IsValid(ChannelStates, ChannelStates)
Check if transition from one ChannelStates to another is valid.
public static bool IsValid(ChannelStates from, ChannelStates to)
Parameters
fromChannelStatesCurrent state.
toChannelStatesNew state.
Returns
- bool
trueif transition is valid; otherwisefalse.
IsValid(OrderStates, OrderStates)
Check if transition from one OrderStates to another is valid.
public static bool IsValid(OrderStates from, OrderStates to)
Parameters
fromOrderStatesCurrent state.
toOrderStatesNew state.
Returns
- bool
trueif transition is valid; otherwisefalse.
IsValid(SessionStates, SessionStates)
Check if transition from one SessionStates to another is valid.
public static bool IsValid(SessionStates from, SessionStates to)
Parameters
fromSessionStatesCurrent state.
toSessionStatesNew state.
Returns
- bool
trueif transition is valid; otherwisefalse.
IsValid(SubscriptionStates, SubscriptionStates)
Check if transition from one SubscriptionStates to another is valid.
public static bool IsValid(SubscriptionStates from, SubscriptionStates to)
Parameters
fromSubscriptionStatesCurrent state.
toSubscriptionStatesNew state.
Returns
- bool
trueif transition is valid; otherwisefalse.
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
fromChannelStatesCurrent state.
toChannelStatesNew state.
contextobjectContext for error message.
logsILogReceiverLog receiver for warnings.
throwOnInvalidboolIf
true, throws InvalidOperationException on invalid transition.
Returns
- bool
trueif transition is valid; otherwisefalse.
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
fromSessionStatesCurrent state.
toSessionStatesNew state.
contextobjectContext for error message.
logsILogReceiverLog receiver for warnings.
throwOnInvalidboolIf
true, throws InvalidOperationException on invalid transition.
Returns
- bool
trueif transition is valid; otherwisefalse.
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
fromSubscriptionStatesCurrent state.
toSubscriptionStatesNew state.
contextobjectContext for error message (e.g., subscription id).
logsILogReceiverLog receiver for warnings.
throwOnInvalidboolIf
true, throws InvalidOperationException on invalid transition.
Returns
- bool
trueif transition is valid; otherwisefalse.
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
fromOrderStates?Current state (null means initial state).
toOrderStatesNew state.
contextobjectContext for error message (e.g., transaction id).
logsILogReceiverLog receiver for warnings.
throwOnInvalidboolIf
true, throws InvalidOperationException on invalid transition.
Returns
- bool
trueif transition is valid; otherwisefalse.