diff --git a/src/Flowsharp.Core/Flowsharp.Core.csproj b/src/Flowsharp.Core/Flowsharp.Core.csproj
index 354fcbfd2..463bd2ac7 100644
--- a/src/Flowsharp.Core/Flowsharp.Core.csproj
+++ b/src/Flowsharp.Core/Flowsharp.Core.csproj
@@ -15,6 +15,7 @@
+
diff --git a/src/Flowsharp.Core/Serialization/Formatters/YamlTokenFormatter.cs b/src/Flowsharp.Core/Serialization/Formatters/YamlTokenFormatter.cs
new file mode 100644
index 000000000..ff3196d5e
--- /dev/null
+++ b/src/Flowsharp.Core/Serialization/Formatters/YamlTokenFormatter.cs
@@ -0,0 +1,29 @@
+using System.Dynamic;
+using Flowsharp.Services;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Linq;
+using YamlDotNet.Serialization;
+
+namespace Flowsharp.Serialization.Formatters
+{
+ public class YamlTokenFormatter : ITokenFormatter
+ {
+ public YamlTokenFormatter()
+ {
+ }
+
+ public string ToString(JToken token)
+ {
+ var expConverter = new ExpandoObjectConverter();
+ var jsonString = token.ToString(Formatting.None);
+ var expandoObject = JsonConvert.DeserializeObject(jsonString, expConverter);
+ var serializer = new SerializerBuilder().Build();
+ var yaml = serializer.Serialize(expandoObject);
+
+ return yaml;
+ }
+
+ public JToken FromString(string data) => JToken.Parse(data);
+ }
+}
\ No newline at end of file
diff --git a/src/Flowsharp.Samples.Console/Flowchart1.yaml b/src/Flowsharp.Samples.Console/Flowchart1.yaml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/src/Flowsharp.Samples.Console/Flowsharp.Samples.Console.csproj b/src/Flowsharp.Samples.Console/Flowsharp.Samples.Console.csproj
index 366c51221..61641f168 100644
--- a/src/Flowsharp.Samples.Console/Flowsharp.Samples.Console.csproj
+++ b/src/Flowsharp.Samples.Console/Flowsharp.Samples.Console.csproj
@@ -13,6 +13,8 @@
+
+
diff --git a/src/Flowsharp.Samples.Console/Program.cs b/src/Flowsharp.Samples.Console/Program.cs
index 2a6931903..f4b0d3a41 100644
--- a/src/Flowsharp.Samples.Console/Program.cs
+++ b/src/Flowsharp.Samples.Console/Program.cs
@@ -24,7 +24,8 @@ namespace Flowsharp.Samples.Console
.AddSingleton()
.AddSingleton()
.AddSingleton()
- .AddSingleton()
+ //.AddSingleton()
+ .AddSingleton()
.AddSingleton()
.AddSingleton()
.AddSingleton()
@@ -43,7 +44,8 @@ namespace Flowsharp.Samples.Console
.AddSingleton();
var serviceProvider = services.BuildServiceProvider();
- var program = serviceProvider.GetRequiredService();
+ var program = serviceProvider.GetRequiredService();
+ //var program = serviceProvider.GetRequiredService();
await program.RunAsync(CancellationToken.None);
}
diff --git a/src/Flowsharp.Samples.Console/SampleWorkflow.yaml b/src/Flowsharp.Samples.Console/SampleWorkflow.yaml
new file mode 100644
index 000000000..e83442b5f
--- /dev/null
+++ b/src/Flowsharp.Samples.Console/SampleWorkflow.yaml
@@ -0,0 +1,153 @@
+status: Idle
+activities:
+- id: 1
+ name: WriteLine
+ textExpression:
+ syntax: PlainText
+ expression: Welcome to Addition Workflow - Long Running edition!
+- id: 2
+ name: WriteLine
+ textExpression:
+ syntax: PlainText
+ expression: Let's run a long-running program.
+- id: 3
+ name: WriteLine
+ textExpression:
+ syntax: PlainText
+ expression: 'Enter first value:'
+- id: 4
+ name: WriteLine
+ textExpression:
+ syntax: PlainText
+ expression: 'Enter second value:'
+- id: 5
+ name: WriteLine
+ textExpression:
+ syntax: JavaScript
+ expression: >-
+ var x = workflow.getVariable('x');
+
+ var y = workflow.getVariable('y');
+
+ var sum = parseInt(x) + parseInt(y);
+
+ x + ' + ' + y + ' = ' + sum;
+- id: 6
+ name: WriteLine
+ textExpression:
+ syntax: PlainText
+ expression: Try again? (Y/N)
+- id: 7
+ name: WriteLine
+ textExpression:
+ syntax: PlainText
+ expression: Bye!
+- id: 8
+ name: ReadLine
+ argumentName: x
+- id: 9
+ name: ReadLine
+ argumentName: y
+- id: 10
+ name: ReadLine
+ argumentName: tryAgain
+- id: 11
+ name: SetVariable
+ variableName: x
+ valueExpression:
+ syntax: JavaScript
+ expression: workflow.getLastResult()
+- id: 12
+ name: SetVariable
+ variableName: y
+ valueExpression:
+ syntax: JavaScript
+ expression: workflow.getLastResult()
+- id: 13
+ name: SetVariable
+ variableName: tryAgain
+ valueExpression:
+ syntax: JavaScript
+ expression: "'y' === workflow.getLastResult().toLowerCase()"
+- id: 14
+ name: IfElse
+ conditionExpression:
+ syntax: JavaScript
+ expression: workflow.getVariable('tryAgain')
+connections:
+- source:
+ activityId: 1
+ endpoint:
+ target:
+ activityId: 2
+- source:
+ activityId: 2
+ endpoint:
+ target:
+ activityId: 3
+- source:
+ activityId: 3
+ endpoint:
+ target:
+ activityId: 8
+- source:
+ activityId: 8
+ endpoint:
+ target:
+ activityId: 11
+- source:
+ activityId: 11
+ endpoint:
+ target:
+ activityId: 4
+- source:
+ activityId: 4
+ endpoint:
+ target:
+ activityId: 9
+- source:
+ activityId: 9
+ endpoint:
+ target:
+ activityId: 12
+- source:
+ activityId: 12
+ endpoint:
+ target:
+ activityId: 5
+- source:
+ activityId: 5
+ endpoint:
+ target:
+ activityId: 6
+- source:
+ activityId: 6
+ endpoint:
+ target:
+ activityId: 10
+- source:
+ activityId: 10
+ endpoint:
+ target:
+ activityId: 13
+- source:
+ activityId: 13
+ endpoint:
+ target:
+ activityId: 14
+- source:
+ activityId: 14
+ endpoint: True
+ target:
+ activityId: 3
+- source:
+ activityId: 14
+ endpoint: False
+ target:
+ activityId: 7
+haltedActivities: []
+scopes:
+- id: 1
+ variables: []
+ lastResult:
+currentScope: 1