Rename PlainTextExpression to Literal

This commit is contained in:
Sipke Schoorstra 2019-09-15 20:34:42 +02:00
parent 4385a4b229
commit 00be822e1e
15 changed files with 50 additions and 50 deletions

View file

@ -27,8 +27,8 @@ namespace Sample02
// Define a workflow.
var workflowBuilder = services.GetRequiredService<IWorkflowBuilder>();
var workflowDefinition = workflowBuilder
.StartWith<WriteLine>(x => x.TextExpression = new PlainTextExpression("Hello world!"))
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Goodbye cruel world..."))
.StartWith<WriteLine>(x => x.TextExpression = new Literal("Hello world!"))
.Then<WriteLine>(x => x.TextExpression = new Literal("Goodbye cruel world..."))
.Build();
// Run the workflow.

View file

@ -31,8 +31,8 @@ namespace Sample03
{
Activities = new[]
{
new ActivityDefinition<WriteLine>("activity-1", new { TextExpression = new PlainTextExpression("Hello world!")}),
new ActivityDefinition<WriteLine>("activity-2", new { TextExpression = new PlainTextExpression("Goodbye cruel world...")})
new ActivityDefinition<WriteLine>("activity-1", new { TextExpression = new Literal("Hello world!")}),
new ActivityDefinition<WriteLine>("activity-2", new { TextExpression = new Literal("Goodbye cruel world...")})
},
Connections = new []
{

View file

@ -14,12 +14,12 @@ namespace Sample04
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith<WriteLine>(x => x.TextExpression = new PlainTextExpression("Welcome to Calculator Workflow!"))
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Enter number 1:"), id: "start")
.StartWith<WriteLine>(x => x.TextExpression = new Literal("Welcome to Calculator Workflow!"))
.Then<WriteLine>(x => x.TextExpression = new Literal("Enter number 1:"), id: "start")
.Then<ReadLine>(x => x.VariableName = "number1")
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Enter number 2:"))
.Then<WriteLine>(x => x.TextExpression = new Literal("Enter number 2:"))
.Then<ReadLine>(x => x.VariableName = "number2")
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Now enter the operation you wish to apply. Options are: add, subtract, multiply or divide:"))
.Then<WriteLine>(x => x.TextExpression = new Literal("Now enter the operation you wish to apply. Options are: add, subtract, multiply or divide:"))
.Then<ReadLine>(x => x.VariableName = "operation")
.Then<Switch>(@switch =>
{
@ -50,7 +50,7 @@ namespace Sample04
}
)
.Add<WriteLine>(x => x.TextExpression = new JavaScriptExpression<string>("`Result: ${result}`"), "showResult")
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Try again? (y/n)"))
.Then<WriteLine>(x => x.TextExpression = new Literal("Try again? (y/n)"))
.Then<ReadLine>(x => x.VariableName = "retry")
.Then<IfElse>(
x => x.Expression = new JavaScriptExpression<bool>("retry.toLowerCase() === 'y'"),
@ -62,7 +62,7 @@ namespace Sample04
ifElse
.When(OutcomeNames.False)
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Bye!"));
.Then<WriteLine>(x => x.TextExpression = new Literal("Bye!"));
});;
}

View file

@ -16,10 +16,10 @@ namespace Sample06
.Then<HttpResponseAction>(
activity =>
{
activity.Content = new PlainTextExpression("<h1>Hello World!</h1><p>Elsa says hi :)</p>");
activity.Content = new Literal("<h1>Hello World!</h1><p>Elsa says hi :)</p>");
activity.ContentType = "text/html";
activity.StatusCode = HttpStatusCode.OK;
activity.ResponseHeaders = new PlainTextExpression("X-Powered-By=Elsa Workflows");
activity.ResponseHeaders = new Literal("X-Powered-By=Elsa Workflows");
}
);
}

View file

@ -36,7 +36,7 @@ namespace Sample07
.Then<SendEmail>(
activity =>
{
activity.From = new PlainTextExpression("approval@acme.com");
activity.From = new Literal("approval@acme.com");
activity.To = new JavaScriptExpression<string>("document.author.email");
activity.Subject = new JavaScriptExpression<string>("`Document received from ${document.author.name}`");
activity.Body = new JavaScriptExpression<string>(
@ -48,10 +48,10 @@ namespace Sample07
.Then<HttpResponseAction>(
activity =>
{
activity.Content = new PlainTextExpression("<h1>Request for Approval Sent</h1><p>Your document has been received and will be reviewed shortly.</p>");
activity.Content = new Literal("<h1>Request for Approval Sent</h1><p>Your document has been received and will be reviewed shortly.</p>");
activity.ContentType = "text/html";
activity.StatusCode = HttpStatusCode.OK;
activity.ResponseHeaders = new PlainTextExpression("X-Powered-By=Elsa Workflows");
activity.ResponseHeaders = new Literal("X-Powered-By=Elsa Workflows");
}
)
.Then<Fork>(
@ -60,12 +60,12 @@ namespace Sample07
{
fork
.When("Approve")
.Then<Signaled>(activity => activity.Signal = new PlainTextExpression("approve"))
.Then<Signaled>(activity => activity.Signal = new Literal("approve"))
.Then("join-signals");
fork
.When("Reject")
.Then<Signaled>(activity => activity.Signal = new PlainTextExpression("reject"))
.Then<Signaled>(activity => activity.Signal = new Literal("reject"))
.Then("join-signals");
}
)
@ -78,7 +78,7 @@ namespace Sample07
.Then<SendEmail>(
activity =>
{
activity.From = new PlainTextExpression("approval@acme.com");
activity.From = new Literal("approval@acme.com");
activity.To = new JavaScriptExpression<string>("document.author.email");
activity.Subject = new JavaScriptExpression<string>("`Document ${document.id} approved!`");
activity.Body = new JavaScriptExpression<string>("`Great job ${document.author.name}, that document is perfect! Keep it up.`");
@ -89,7 +89,7 @@ namespace Sample07
.Then<SendEmail>(
activity =>
{
activity.From = new PlainTextExpression("approval@acme.com");
activity.From = new Literal("approval@acme.com");
activity.To = new JavaScriptExpression<string>("document.author.email");
activity.Subject = new JavaScriptExpression<string>("`Document ${document.id} rejected`");
activity.Body = new JavaScriptExpression<string>("`Sorry ${document.author.name}, that document isn't good enough. Please try again.`");

View file

@ -48,7 +48,7 @@ namespace Sample08.Workflows
.Then<HttpResponseAction>(
activity =>
{
activity.Content = new PlainTextExpression("<h1>Order Received</h1><p>Your order has been received. Waiting for shipment.</p>");
activity.Content = new Literal("<h1>Order Received</h1><p>Your order has been received. Waiting for shipment.</p>");
activity.ContentType = "text/html";
activity.StatusCode = HttpStatusCode.Accepted;
}
@ -60,7 +60,7 @@ namespace Sample08.Workflows
.Then<SendEmail>(
activity =>
{
activity.From = new PlainTextExpression("shipment@acme.com");
activity.From = new Literal("shipment@acme.com");
activity.To = new JavaScriptExpression<string>("order.customer.email");
activity.Subject = new JavaScriptExpression<string>("`Your order with ID #${order.id} has been shipped!`");
activity.Body = new JavaScriptExpression<string>(

View file

@ -10,7 +10,7 @@ namespace Sample10
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("Hello World!"));
.StartWith<WriteLine>(activity => activity.TextExpression = new Literal("Hello World!"));
}
}
}

View file

@ -13,9 +13,9 @@ namespace Sample11
{
builder
.StartWith<WriteLine>(activity => activity.TextExpression = new JavaScriptExpression<string>("`Workflow started with correlation ID \"${correlationId()}\".`"))
.Then<Signaled>(activity => activity.Signal = new PlainTextExpression("Proceed"))
.Then<Signaled>(activity => activity.Signal = new Literal("Proceed"))
.Then<WriteLine>(activity => activity.TextExpression = new JavaScriptExpression<string>("`Signal received for workflow with correlation ID: \"${correlationId()}\"`"))
.Then<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("Workflow finished."));
.Then<WriteLine>(activity => activity.TextExpression = new Literal("Workflow finished."));
}
}
}

View file

@ -12,27 +12,27 @@ namespace Sample12
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("Workflow started. Waiting for user action."))
.StartWith<WriteLine>(activity => activity.TextExpression = new Literal("Workflow started. Waiting for user action."))
.Then<UserTask>(
activity => activity.Actions = new[] { "Accept", "Reject", "Needs Work" },
userTask =>
{
userTask
.When("Accept")
.Then<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("Great! Your work has been accepted."))
.Then<WriteLine>(activity => activity.TextExpression = new Literal("Great! Your work has been accepted."))
.Then("Exit");
userTask.When("Reject")
.Then<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("Sorry! Your work has been rejected."))
.Then<WriteLine>(activity => activity.TextExpression = new Literal("Sorry! Your work has been rejected."))
.Then("Exit");
userTask.When("Needs Work")
.Then<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("So close! Your work needs a little bit more work."))
.Then<WriteLine>(activity => activity.TextExpression = new Literal("So close! Your work needs a little bit more work."))
.Then("WaitUser");
},
"WaitUser"
)
.Add<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("Workflow finished."), "Exit");
.Add<WriteLine>(activity => activity.TextExpression = new Literal("Workflow finished."), "Exit");
}
}
}

View file

@ -10,7 +10,7 @@ namespace Sample13
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith<WriteLine>(x => x.TextExpression = new PlainTextExpression("Hi! What's your name?"))
.StartWith<WriteLine>(x => x.TextExpression = new Literal("Hi! What's your name?"))
.Then<ReadLine>(id: "name")
.Then<WriteLine>(x => x.TextExpression = new JavaScriptExpression<string>("`${name.output.text}, that's a great name! Now, what's your age?`"))
.Then<ReadLine>(id: "age")

View file

@ -10,7 +10,7 @@ namespace Sample14
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("Hello World!"));
.StartWith<WriteLine>(activity => activity.TextExpression = new Literal("Hello World!"));
}
}
}

View file

@ -10,7 +10,7 @@ namespace Sample15
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith<WriteLine>(activity => activity.TextExpression = new PlainTextExpression("Hello World!"));
.StartWith<WriteLine>(activity => activity.TextExpression = new Literal("Hello World!"));
}
}
}

View file

@ -23,7 +23,7 @@ namespace Elsa.Activities.Timers.Activities
public WorkflowExpression<string> CronExpression
{
get => GetState(() => new PlainTextExpression("* * * * *"));
get => GetState(() => new Literal("* * * * *"));
set => SetState(value);
}

View file

@ -23,7 +23,7 @@ namespace Elsa.Activities.Workflows
public WorkflowExpression<string> ActivityType
{
get => GetState(() => new PlainTextExpression(""));
get => GetState(() => new Literal(""));
set => SetState(value);
}
@ -35,7 +35,7 @@ namespace Elsa.Activities.Workflows
public WorkflowExpression<string> CorrelationId
{
get => GetState(() => new PlainTextExpression(Guid.NewGuid().ToString()));
get => GetState(() => new Literal(Guid.NewGuid().ToString()));
set => SetState(value);
}

View file

@ -1,16 +1,16 @@
namespace Elsa.Expressions
{
public class PlainTextExpression<T> : WorkflowExpression<T>
{
public PlainTextExpression(string expression) : base(PlainTextEvaluator.SyntaxName, expression)
{
}
}
public class PlainTextExpression : PlainTextExpression<string>
{
public PlainTextExpression(string expression) : base(expression)
{
}
}
namespace Elsa.Expressions
{
public class PlainTextExpression<T> : WorkflowExpression<T>
{
public PlainTextExpression(string expression) : base(PlainTextEvaluator.SyntaxName, expression)
{
}
}
public class Literal : PlainTextExpression<string>
{
public Literal(string expression) : base(expression)
{
}
}
}