StateDiagram Class

A state diagram: states, linked by transitions, with start and end states, choices, forks and joins, and composite states that hold other states, in concurrent regions or not (Mermaid stateDiagram-v2).

public sealed class StateDiagram : Diagram
Inheritance
Diagram StateDiagram

Constructors

NameDescription
StateDiagram()

StateDiagram()

StateDiagram.cs
public StateDiagram()

No documentation is available.

Properties

NameDescription
ClassDefinitionsGets the styles of the CSS classes of the states, by name (Mermaid classDef). The class default applies to every state.
DirectionGets or sets the direction of the transitions. The default is DiagramDirection.TopToBottom.
NotesGets the notes.
StatesGets the top-level states.
TransitionsGets the transitions, drawn in order.

ClassDefinitions

StateDiagram.cs

Gets the styles of the CSS classes of the states, by name (Mermaid classDef). The class default applies to every state.

public IDictionary<string, DiagramStyle> ClassDefinitions { get; }

Gets or sets the direction of the transitions. The default is DiagramDirection.TopToBottom.

public DiagramDirection Direction { get; set; }

Property value

DiagramDirection

Gets the notes.

public IList<StateNote> Notes { get; }

Property value

IList<StateNote>

Gets the top-level states.

public IList<StateDiagramState> States { get; }

Transitions

StateDiagram.cs

Gets the transitions, drawn in order.

public IList<StateTransition> Transitions { get; }

Methods

NameDescription
AddNote(StateDiagramState, DiagramText, StateNotePosition)Adds a note next to a state.
AddState(string, DiagramText?, StateKind)Adds a top-level state.
AddTransition(StateDiagramState, StateDiagramState, DiagramText?)Adds a transition.
EnumerateStates()Enumerates the states and the states of their regions, depth first.
Find(string)Finds a state by identifier, in the diagram and its composite states.

AddNote(StateDiagramState, DiagramText, StateNotePosition)

StateDiagram.cs

Adds a note next to a state.

public StateNote AddNote(StateDiagramState state, DiagramText text, StateNotePosition position = StateNotePosition.Right)

Parameters

state StateDiagramState
The state.
text DiagramText
The text of the note.
position StateNotePosition
The side of the state.

Returns

StateNote The note.

AddState(string, DiagramText?, StateKind)

StateDiagram.cs

Adds a top-level state.

public StateDiagramState AddState(string id, DiagramText? label = null, StateKind kind = StateKind.Normal)

Parameters

id string
The identifier of the state, unique in the diagram.
label DiagramText?
The name shown, or null to show the identifier.
kind StateKind
The kind of the state.

Returns

StateDiagramState The state.

AddTransition(StateDiagramState, StateDiagramState, DiagramText?)

StateDiagram.cs

Adds a transition.

public StateTransition AddTransition(StateDiagramState from, StateDiagramState to, DiagramText? label = null)

Parameters

from StateDiagramState
The state the transition leaves.
to StateDiagramState
The state the transition enters.
label DiagramText?
The text of the transition, or null for none.

Returns

StateTransition The transition.

EnumerateStates()

StateDiagram.cs

Enumerates the states and the states of their regions, depth first.

public IEnumerable<StateDiagramState> EnumerateStates()

Find(string)

StateDiagram.cs

Finds a state by identifier, in the diagram and its composite states.

public StateDiagramState? Find(string id)

Parameters

id string
The identifier.

Returns

StateDiagramState? The state, or null when there is none.