diff --git a/src/Flowsharp.Core/Flowsharp.Core.csproj b/src/Flowsharp.Core/Flowsharp.Core.csproj
index 463bd2ac7..c1f163431 100644
--- a/src/Flowsharp.Core/Flowsharp.Core.csproj
+++ b/src/Flowsharp.Core/Flowsharp.Core.csproj
@@ -18,8 +18,4 @@
-
-
-
-
diff --git a/src/Flowsharp.Core/Services/ActivityHandler.cs b/src/Flowsharp.Core/Handlers/ActivityHandler.cs
similarity index 94%
rename from src/Flowsharp.Core/Services/ActivityHandler.cs
rename to src/Flowsharp.Core/Handlers/ActivityHandler.cs
index 8193d5de6..ed6755afb 100644
--- a/src/Flowsharp.Core/Services/ActivityHandler.cs
+++ b/src/Flowsharp.Core/Handlers/ActivityHandler.cs
@@ -4,7 +4,7 @@ using System.Threading.Tasks;
using Flowsharp.Models;
using Flowsharp.Results;
-namespace Flowsharp.Services
+namespace Flowsharp.Handlers
{
public abstract class ActivityHandler : IActivityHandler where T : IActivity
{
@@ -23,7 +23,7 @@ namespace Flowsharp.Services
protected virtual ActivityExecutionResult OnResume(T activity, WorkflowExecutionContext workflowContext) => Noop();
protected HaltResult Halt() => new HaltResult();
- protected ActivateEndpointResult ActivateEndpoint(string name = null) => new ActivateEndpointResult(name);
+ protected TriggerEndpointResult TriggerEndpoint(string name = null) => new TriggerEndpointResult(name);
protected ScheduleActivityResult ScheduleActivity(IActivity activity) => new ScheduleActivityResult(activity);
protected ReturnValueResult SetReturnValue(object value) => new ReturnValueResult(value);
protected FinishWorkflowResult Finish() => new FinishWorkflowResult();
diff --git a/src/Flowsharp.Core/Services/IActivityHandler.cs b/src/Flowsharp.Core/Handlers/IActivityHandler.cs
similarity index 97%
rename from src/Flowsharp.Core/Services/IActivityHandler.cs
rename to src/Flowsharp.Core/Handlers/IActivityHandler.cs
index 6e6a56a8a..583cb13aa 100644
--- a/src/Flowsharp.Core/Services/IActivityHandler.cs
+++ b/src/Flowsharp.Core/Handlers/IActivityHandler.cs
@@ -4,7 +4,7 @@ using System.Threading.Tasks;
using Flowsharp.Models;
using Flowsharp.Results;
-namespace Flowsharp.Services
+namespace Flowsharp.Handlers
{
public interface IActivityHandler
{
diff --git a/src/Flowsharp.Core/Handlers/IfElseHandler.cs b/src/Flowsharp.Core/Handlers/IfElseHandler.cs
index f02e5d445..7e4c1226b 100644
--- a/src/Flowsharp.Core/Handlers/IfElseHandler.cs
+++ b/src/Flowsharp.Core/Handlers/IfElseHandler.cs
@@ -20,7 +20,7 @@ namespace Flowsharp.Handlers
protected override async Task OnExecuteAsync(IfElse activity, WorkflowExecutionContext workflowContext, CancellationToken cancellationToken)
{
var result = await expressionEvaluator.EvaluateAsync(activity.ConditionExpression, workflowContext, cancellationToken);
- return ActivateEndpoint(result ? "True" : "False");
+ return TriggerEndpoint(result ? "True" : "False");
}
}
}
\ No newline at end of file
diff --git a/src/Flowsharp.Core/Handlers/SetVariableHandler.cs b/src/Flowsharp.Core/Handlers/SetVariableHandler.cs
index 90691d365..fad367993 100644
--- a/src/Flowsharp.Core/Handlers/SetVariableHandler.cs
+++ b/src/Flowsharp.Core/Handlers/SetVariableHandler.cs
@@ -21,7 +21,7 @@ namespace Flowsharp.Handlers
{
var value = await expressionEvaluator.EvaluateAsync(activity.ValueExpression, workflowContext, cancellationToken);
workflowContext.CurrentScope.SetVariable(activity.VariableName, value);
- return ActivateEndpoint();
+ return TriggerEndpoint();
}
}
}
\ No newline at end of file
diff --git a/src/Flowsharp.Core/Results/ActivateEndpointResult.cs b/src/Flowsharp.Core/Results/TriggerEndpointResult.cs
similarity index 82%
rename from src/Flowsharp.Core/Results/ActivateEndpointResult.cs
rename to src/Flowsharp.Core/Results/TriggerEndpointResult.cs
index ded61128c..61e301ec7 100644
--- a/src/Flowsharp.Core/Results/ActivateEndpointResult.cs
+++ b/src/Flowsharp.Core/Results/TriggerEndpointResult.cs
@@ -6,9 +6,9 @@ namespace Flowsharp.Results
///
/// A result that carries information about the next activity to execute.
///
- public class ActivateEndpointResult : ActivityExecutionResult
+ public class TriggerEndpointResult : ActivityExecutionResult
{
- public ActivateEndpointResult(string endpointName = null)
+ public TriggerEndpointResult(string endpointName = null)
{
EndpointName = endpointName;
}
diff --git a/src/Flowsharp.Core/Serialization/Formatters/ITokenFormatter.cs b/src/Flowsharp.Core/Serialization/Formatters/ITokenFormatter.cs
index 6a40f0a22..ca3a01f1c 100644
--- a/src/Flowsharp.Core/Serialization/Formatters/ITokenFormatter.cs
+++ b/src/Flowsharp.Core/Serialization/Formatters/ITokenFormatter.cs
@@ -1,6 +1,6 @@
using Newtonsoft.Json.Linq;
-namespace Flowsharp.Services
+namespace Flowsharp.Serialization.Formatters
{
public interface ITokenFormatter
{
diff --git a/src/Flowsharp.Core/Serialization/IWorkflowSerializer.cs b/src/Flowsharp.Core/Serialization/IWorkflowSerializer.cs
index 29c732620..0962c4ce3 100644
--- a/src/Flowsharp.Core/Serialization/IWorkflowSerializer.cs
+++ b/src/Flowsharp.Core/Serialization/IWorkflowSerializer.cs
@@ -1,7 +1,6 @@
using Flowsharp.Models;
-using Newtonsoft.Json.Linq;
-namespace Flowsharp.Services
+namespace Flowsharp.Serialization
{
public interface IWorkflowSerializer
{
diff --git a/src/Flowsharp.Core/Serialization/Tokenizers/ITokenizer.cs b/src/Flowsharp.Core/Serialization/Tokenizers/ITokenizer.cs
index 2f59ad49b..22c8d5dca 100644
--- a/src/Flowsharp.Core/Serialization/Tokenizers/ITokenizer.cs
+++ b/src/Flowsharp.Core/Serialization/Tokenizers/ITokenizer.cs
@@ -1,7 +1,6 @@
-using Flowsharp.Serialization;
using Newtonsoft.Json.Linq;
-namespace Flowsharp.Services
+namespace Flowsharp.Serialization.Tokenizers
{
public interface ITokenizer
{
diff --git a/src/Flowsharp.Core/Serialization/Tokenizers/ITokenizerInvoker.cs b/src/Flowsharp.Core/Serialization/Tokenizers/ITokenizerInvoker.cs
index 03283e01e..b2e5a5678 100644
--- a/src/Flowsharp.Core/Serialization/Tokenizers/ITokenizerInvoker.cs
+++ b/src/Flowsharp.Core/Serialization/Tokenizers/ITokenizerInvoker.cs
@@ -1,7 +1,6 @@
-using Flowsharp.Serialization;
-using Newtonsoft.Json.Linq;
+using Newtonsoft.Json.Linq;
-namespace Flowsharp.Services
+namespace Flowsharp.Serialization.Tokenizers
{
public interface ITokenizerInvoker
{
diff --git a/src/Flowsharp.Core/Serialization/Tokenizers/Tokenizer.cs b/src/Flowsharp.Core/Serialization/Tokenizers/Tokenizer.cs
index 3b6b693a6..c7404c52f 100644
--- a/src/Flowsharp.Core/Serialization/Tokenizers/Tokenizer.cs
+++ b/src/Flowsharp.Core/Serialization/Tokenizers/Tokenizer.cs
@@ -1,7 +1,6 @@
-using Flowsharp.Serialization;
using Newtonsoft.Json.Linq;
-namespace Flowsharp.Services
+namespace Flowsharp.Serialization.Tokenizers
{
public abstract class Tokenizer : ITokenizer
{
diff --git a/src/Flowsharp.Core/Serialization/Tokenizers/TokenizerInvoker.cs b/src/Flowsharp.Core/Serialization/Tokenizers/TokenizerInvoker.cs
index 049a41a2f..7ea42a81a 100644
--- a/src/Flowsharp.Core/Serialization/Tokenizers/TokenizerInvoker.cs
+++ b/src/Flowsharp.Core/Serialization/Tokenizers/TokenizerInvoker.cs
@@ -1,9 +1,8 @@
using System.Collections.Generic;
using System.Linq;
-using Flowsharp.Serialization;
using Newtonsoft.Json.Linq;
-namespace Flowsharp.Services
+namespace Flowsharp.Serialization.Tokenizers
{
public class TokenizerInvoker : ITokenizerInvoker
{
diff --git a/src/Flowsharp.Core/Serialization/Tokenizers/WorkflowTokenizer.cs b/src/Flowsharp.Core/Serialization/Tokenizers/WorkflowTokenizer.cs
index a1280d86c..62c44ee65 100644
--- a/src/Flowsharp.Core/Serialization/Tokenizers/WorkflowTokenizer.cs
+++ b/src/Flowsharp.Core/Serialization/Tokenizers/WorkflowTokenizer.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
+using Flowsharp.Handlers;
using Flowsharp.Models;
using Flowsharp.Services;
using Newtonsoft.Json;
diff --git a/src/Flowsharp.Core/Serialization/WorkflowSerializer.cs b/src/Flowsharp.Core/Serialization/WorkflowSerializer.cs
index 2cacb6d36..7c0066c12 100644
--- a/src/Flowsharp.Core/Serialization/WorkflowSerializer.cs
+++ b/src/Flowsharp.Core/Serialization/WorkflowSerializer.cs
@@ -1,4 +1,5 @@
using Flowsharp.Models;
+using Flowsharp.Serialization.Formatters;
using Flowsharp.Serialization.Tokenizers;
using Flowsharp.Services;
diff --git a/src/Flowsharp.Core/Services/ActivityInvoker.cs b/src/Flowsharp.Core/Services/ActivityInvoker.cs
index 1ad60868c..0c7b756bc 100644
--- a/src/Flowsharp.Core/Services/ActivityInvoker.cs
+++ b/src/Flowsharp.Core/Services/ActivityInvoker.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Flowsharp.Handlers;
using Flowsharp.Models;
using Flowsharp.Results;
diff --git a/src/Flowsharp.Core/Services/IWorkflowInvoker.cs b/src/Flowsharp.Core/Services/IWorkflowInvoker.cs
index 0111b558c..af4478985 100644
--- a/src/Flowsharp.Core/Services/IWorkflowInvoker.cs
+++ b/src/Flowsharp.Core/Services/IWorkflowInvoker.cs
@@ -9,5 +9,6 @@ namespace Flowsharp.Services
{
IActivityInvoker ActivityInvoker { get; }
Task InvokeAsync(Workflow workflow, IActivity startActivity = default, CancellationToken cancellationToken = default);
+ Task ResumeAsync(Workflow workflow, IActivity startActivity = default, CancellationToken cancellationToken = default);
}
}
diff --git a/src/Flowsharp.Core/Services/WorkflowInvoker.cs b/src/Flowsharp.Core/Services/WorkflowInvoker.cs
index 582316061..ed4902c55 100644
--- a/src/Flowsharp.Core/Services/WorkflowInvoker.cs
+++ b/src/Flowsharp.Core/Services/WorkflowInvoker.cs
@@ -53,6 +53,12 @@ namespace Flowsharp.Services
return workflowExecutionContext;
}
+ public Task ResumeAsync(Workflow workflow, IActivity startActivity = default, CancellationToken cancellationToken = default)
+ {
+ workflow.Status = WorkflowStatus.Resuming;
+ return InvokeAsync(workflow, startActivity, cancellationToken);
+ }
+
private async Task ExecuteActivityAsync(WorkflowExecutionContext workflowContext, IActivity activity, bool isResuming, CancellationToken cancellationToken)
{
try
diff --git a/src/Flowsharp.Samples.Console/Handlers/ReadLineHandler.cs b/src/Flowsharp.Samples.Console/Handlers/ReadLineHandler.cs
index 89f2644ee..13c7a8c4d 100644
--- a/src/Flowsharp.Samples.Console/Handlers/ReadLineHandler.cs
+++ b/src/Flowsharp.Samples.Console/Handlers/ReadLineHandler.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using Flowsharp.Handlers;
using Flowsharp.Models;
using Flowsharp.Results;
using Flowsharp.Samples.Console.Activities;
@@ -28,7 +29,7 @@ namespace Flowsharp.Samples.Console.Handlers
var value = await input.ReadLineAsync();
workflowContext.SetLastResult(value);
- return ActivateEndpoint();
+ return TriggerEndpoint();
}
@@ -36,7 +37,7 @@ namespace Flowsharp.Samples.Console.Handlers
{
var receivedInput = workflowContext.Workflow.Arguments[activity.ArgumentName];
workflowContext.SetLastResult(receivedInput);
- return ActivateEndpoint();
+ return TriggerEndpoint();
}
}
}
\ No newline at end of file
diff --git a/src/Flowsharp.Samples.Console/Handlers/WriteLineHandler.cs b/src/Flowsharp.Samples.Console/Handlers/WriteLineHandler.cs
index cfb09cdbe..a763a55dd 100644
--- a/src/Flowsharp.Samples.Console/Handlers/WriteLineHandler.cs
+++ b/src/Flowsharp.Samples.Console/Handlers/WriteLineHandler.cs
@@ -2,6 +2,7 @@
using System.Threading;
using System.Threading.Tasks;
using Flowsharp.Expressions;
+using Flowsharp.Handlers;
using Flowsharp.Models;
using Flowsharp.Results;
using Flowsharp.Samples.Console.Activities;
@@ -31,7 +32,7 @@ namespace Flowsharp.Samples.Console.Handlers
{
var text = await evaluator.EvaluateAsync(activity.TextExpression, workflowContext, cancellationToken);
await output.WriteLineAsync(text);
- return ActivateEndpoint();
+ return TriggerEndpoint();
}
}
}
diff --git a/src/Flowsharp.Samples.Console/Programs/AdditionWorkflowProgram.cs b/src/Flowsharp.Samples.Console/Programs/AdditionWorkflowProgram.cs
index a5ff68e8a..7c705285e 100644
--- a/src/Flowsharp.Samples.Console/Programs/AdditionWorkflowProgram.cs
+++ b/src/Flowsharp.Samples.Console/Programs/AdditionWorkflowProgram.cs
@@ -1,6 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using Flowsharp.Samples.Console.Workflows;
+using Flowsharp.Serialization;
using Flowsharp.Services;
namespace Flowsharp.Samples.Console.Programs
diff --git a/src/Flowsharp.Samples.Console/Programs/AdditionWorkflowProgramLongRunning.cs b/src/Flowsharp.Samples.Console/Programs/AdditionWorkflowProgramLongRunning.cs
index 7d70b0445..6994785ff 100644
--- a/src/Flowsharp.Samples.Console/Programs/AdditionWorkflowProgramLongRunning.cs
+++ b/src/Flowsharp.Samples.Console/Programs/AdditionWorkflowProgramLongRunning.cs
@@ -3,6 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using Flowsharp.Models;
using Flowsharp.Samples.Console.Workflows;
+using Flowsharp.Serialization;
using Flowsharp.Services;
namespace Flowsharp.Samples.Console.Programs
diff --git a/src/Flowsharp.Samples.Console/Programs/FileBasedWorkflowProgram.cs b/src/Flowsharp.Samples.Console/Programs/FileBasedWorkflowProgram.cs
index 7caf4e137..41679c13c 100644
--- a/src/Flowsharp.Samples.Console/Programs/FileBasedWorkflowProgram.cs
+++ b/src/Flowsharp.Samples.Console/Programs/FileBasedWorkflowProgram.cs
@@ -3,6 +3,8 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Flowsharp.Models;
+using Flowsharp.Samples.Console.Activities;
+using Flowsharp.Serialization;
using Flowsharp.Services;
namespace Flowsharp.Samples.Console.Programs
@@ -29,20 +31,19 @@ namespace Flowsharp.Samples.Console.Programs
while (workflowContext.Workflow.Status == WorkflowStatus.Halted)
{
- workflowContext = await ReadAndResumeAsync(workflowContext.Workflow, "x", cancellationToken);
- workflowContext = await ReadAndResumeAsync(workflowContext.Workflow, "y", cancellationToken);
- workflowContext = await ReadAndResumeAsync(workflowContext.Workflow, "tryAgain", cancellationToken);
+ workflowContext = await ReadAndResumeAsync(workflowContext.Workflow, cancellationToken);
+ workflowContext = await ReadAndResumeAsync(workflowContext.Workflow, cancellationToken);
+ workflowContext = await ReadAndResumeAsync(workflowContext.Workflow, cancellationToken);
}
System.Console.WriteLine(data);
}
- private async Task ReadAndResumeAsync(Workflow workflow, string argumentName, CancellationToken cancellationToken)
+ private async Task ReadAndResumeAsync(Workflow workflow, CancellationToken cancellationToken)
{
- var haltedActivity = workflow.HaltedActivities.Single();
- workflow.Arguments[argumentName] = System.Console.ReadLine();
- workflow.Status = WorkflowStatus.Resuming;
- return await workflowInvoker.InvokeAsync(workflow, haltedActivity, cancellationToken);
+ var haltedActivity = (ReadLine)workflow.HaltedActivities.Single();
+ workflow.Arguments[haltedActivity.ArgumentName] = System.Console.ReadLine();
+ return await workflowInvoker.ResumeAsync(workflow, haltedActivity, cancellationToken);
}
}
}
\ No newline at end of file