private string GetDirection(MermaidFlowChartDirection direction) { switch (direction) { case MermaidFlowChartDirection.TopBottom: return("TB"); case MermaidFlowChartDirection.BottomTop: return("BT"); case MermaidFlowChartDirection.RightLeft: return("RL"); case MermaidFlowChartDirection.LeftRight: return("LR"); default: throw new InvalidOperationException($"Unexpected Mermaid flow chart direction value {direction}"); } }
public string Process( Graph <IState, ITransition> graph, MermaidFlowChartDirection direction = MermaidFlowChartDirection.TopBottom, bool includeStartState = false) { var sb = new StringBuilder(); sb.AppendLine($"graph {this.GetDirection(direction)}"); foreach (var edge in graph.Edges) { if (!includeStartState && edge.Source.GetType() == typeof(StartState)) { continue; } sb.AppendLine($"{ToMermaid(edge.Source)}-->|{edge.Action.Name}|{ToMermaid(edge.Target)}"); } return(sb.ToString()); }