Show / Hide Table of Contents

    Class StateMachine<TStateEnum>

    Lockfree enum-based state machine. Transitions are O(1).

    Inheritance
    Object
    StateMachine<TStateEnum>
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Microsoft.Graph.Communications.Common
    Assembly: Microsoft.Graph.Communications.Common.dll
    Syntax
    public sealed class StateMachine<TStateEnum>
    
        where TStateEnum : struct, IComparable, IFormattable, IConvertible
    Type Parameters
    Name Description
    TStateEnum

    The enum type which represents state.

    Constructors

    StateMachine(TStateEnum, StateMachine<TStateEnum>.Transition[])

    Initializes a new instance of the StateMachine<TStateEnum> class.

    Declaration
    public StateMachine(TStateEnum initalState, StateMachine<TStateEnum>.Transition[] transitions)
    Parameters
    Type Name Description
    TStateEnum initalState

    State of the inital.

    StateMachine.Transition<>[] transitions

    The transitions.

    Properties

    State

    Gets the state.

    Declaration
    public TStateEnum State { get; }
    Property Value
    Type Description
    TStateEnum

    The state.

    Methods

    ToString()

    Returns a String that represents this instance.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    A String that represents this instance.

    Overrides
    Object.ToString()

    TransitionState(TStateEnum)

    Transition to next state. Transition to same state is not allowed. Non valid transition throws exception.

    Declaration
    public TStateEnum TransitionState(TStateEnum newState)
    Parameters
    Type Name Description
    TStateEnum newState

    The new state.

    Returns
    Type Description
    TStateEnum

    Previous state

    Exceptions
    Type Condition
    Exception

    If transition is not allow, exception is thrown.

    TransitionStateSafe(TStateEnum)

    Transition to the next state. Transition to same state has to be allowed via transitions. Non valid transition returns null.

    Declaration
    public TStateEnum? TransitionStateSafe(TStateEnum newState)
    Parameters
    Type Name Description
    TStateEnum newState

    The new state.

    Returns
    Type Description
    Nullable<TStateEnum>

    Previous state or null; if transition is not valid.

    Extension Methods

    AdditionalDataExtensions.SetInAdditionalData(Object, String, Object)
    Extensions.Pin(Object)
    Extensions.ChangeType(Object, Type)
    Extensions.ChangeType<T>(Object)
    Extensions.TryDispose(Object, IGraphLogger)
    ReflectionUtils.GetPropertyUsingReflection(Object, String)
    ReflectionUtils.SetPropertyUsingReflection(Object, String, Object)
    Validator.IsNull(Object, String, String)
    Validator.NotNull<T>(T, String, String)
    Validator.Equals<T>(T, T, String, String)
    Validator.Equals<T, TE>(T, T, String)
    Validator.NotEquals<T>(T, T, String, String)
    Back to top Copyright (c) Microsoft Corporation. All rights reserved.