From f3fd1487d1aec01a28bde4ec7e24e848f261d17c Mon Sep 17 00:00:00 2001 From: Marcin Sulecki Date: Fri, 27 May 2022 09:56:18 +0200 Subject: [PATCH] Moved formating state to the base class --- src/Stateless/Graph/GraphStyleBase.cs | 7 +++++++ src/Stateless/Graph/UmlDotGraphStyle.cs | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Stateless/Graph/GraphStyleBase.cs b/src/Stateless/Graph/GraphStyleBase.cs index 32788e86..dcf74ffd 100644 --- a/src/Stateless/Graph/GraphStyleBase.cs +++ b/src/Stateless/Graph/GraphStyleBase.cs @@ -48,6 +48,13 @@ public abstract class GraphStyleBase /// public abstract string FormatOneDecisionNode(string nodeName, string label); + /// + /// Returns the formatted text for a initial state. + /// + /// + /// + public abstract string FormatInitialState(string initialStateName); + /// /// Returns the formatted text for all the transitions found in the state graph. /// This form, which can be overridden, determines the type of each transition and passes the appropriate diff --git a/src/Stateless/Graph/UmlDotGraphStyle.cs b/src/Stateless/Graph/UmlDotGraphStyle.cs index 0d47b17d..42eabbdb 100644 --- a/src/Stateless/Graph/UmlDotGraphStyle.cs +++ b/src/Stateless/Graph/UmlDotGraphStyle.cs @@ -122,5 +122,20 @@ internal string FormatOneLine(string fromNodeName, string toNodeName, string lab { return $"\"{fromNodeName}\" -> \"{toNodeName}\" [style=\"solid\", label=\"{label}\"];"; } + + /// + /// Generate the text for a initial state + /// + /// Name of state + /// + public override string FormatInitialState(string initialStateName) + { + string f = System.Environment.NewLine + $" init [label=\"\", shape=point];"; + f += System.Environment.NewLine + $" init -> \"{initialStateName}\"[style = \"solid\"]"; + + f += System.Environment.NewLine + "}"; + + return f; + } } }