Rename Literal to LiteralExpression
This commit is contained in:
parent
ce49cf0263
commit
f8115219ae
|
|
@ -25,8 +25,8 @@ namespace Sample02
|
|||
// Define a workflow.
|
||||
var workflowBuilder = services.GetRequiredService<IWorkflowBuilder>();
|
||||
var workflowDefinition = workflowBuilder
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new Literal("Hello world!"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new Literal("Goodbye cruel world..."))
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new LiteralExpression("Hello world!"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("Goodbye cruel world..."))
|
||||
.Build();
|
||||
|
||||
// Start the workflow.
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ namespace Sample03
|
|||
{
|
||||
Activities = new[]
|
||||
{
|
||||
new ActivityDefinition<WriteLine>("activity-1", new { TextExpression = new Literal("Hello world!")}),
|
||||
new ActivityDefinition<WriteLine>("activity-2", new { TextExpression = new Literal("Goodbye cruel world...")})
|
||||
new ActivityDefinition<WriteLine>("activity-1", new { TextExpression = new LiteralExpression("Hello world!")}),
|
||||
new ActivityDefinition<WriteLine>("activity-2", new { TextExpression = new LiteralExpression("Goodbye cruel world...")})
|
||||
},
|
||||
Connections = new []
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ namespace Sample04
|
|||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new Literal("Welcome to Calculator Workflow!"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new Literal("Enter number 1:"), id: "start")
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new LiteralExpression("Welcome to Calculator Workflow!"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("Enter number 1:"), id: "start")
|
||||
.Then<ReadLine>(x => x.VariableName = "number1")
|
||||
.Then<WriteLine>(x => x.TextExpression = new Literal("Enter number 2:"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("Enter number 2:"))
|
||||
.Then<ReadLine>(x => x.VariableName = "number2")
|
||||
.Then<WriteLine>(x => x.TextExpression = new Literal("Now enter the operation you wish to apply. Options are: add, subtract, multiply or divide:"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("Now enter the operation you wish to apply. Options are: add, subtract, multiply or divide:"))
|
||||
.Then<ReadLine>(x => x.VariableName = "operation")
|
||||
.Then<Switch>(@switch =>
|
||||
{
|
||||
|
|
@ -49,7 +49,7 @@ namespace Sample04
|
|||
}
|
||||
)
|
||||
.Add<WriteLine>(x => x.TextExpression = new JavaScriptExpression<string>("`Result: ${result}`"), "showResult")
|
||||
.Then<WriteLine>(x => x.TextExpression = new Literal("Try again? (y/n)"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("Try again? (y/n)"))
|
||||
.Then<ReadLine>(x => x.VariableName = "retry")
|
||||
.Then<IfElse>(
|
||||
x => x.Expression = new JavaScriptExpression<bool>("retry.toLowerCase() === 'y'"),
|
||||
|
|
@ -61,7 +61,7 @@ namespace Sample04
|
|||
|
||||
ifElse
|
||||
.When(OutcomeNames.False)
|
||||
.Then<WriteLine>(x => x.TextExpression = new Literal("Bye!"));
|
||||
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("Bye!"));
|
||||
});;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,7 @@ namespace Sample05
|
|||
services
|
||||
.AddWorkflows()
|
||||
.AddConsoleActivities()
|
||||
.AddTimerActivities(options => options.Configure(x => x.SweepInterval = Period.FromSeconds(1)))
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
.AddTimerActivities(options => options.Configure(x => x.SweepInterval = Period.FromSeconds(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ namespace Sample05
|
|||
builder
|
||||
.WithId("RecurringWorkflow")
|
||||
.AsSingleton()
|
||||
.StartWith<TimerEvent>(x => x.TimeoutExpression = new PlainTextExpression<TimeSpan>("00:00:05"), "Timer")
|
||||
.StartWith<TimerEvent>(x => x.TimeoutExpression = new LiteralExpression<TimeSpan>("00:00:05"), "Timer")
|
||||
.Then<WriteLine>(x => x.TextExpression = new JavaScriptExpression<string>("`Trigger received. The time is: ${new Date().toISOString()}`"))
|
||||
.Then("Timer");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ namespace Sample06
|
|||
.Then<HttpResponseAction>(
|
||||
activity =>
|
||||
{
|
||||
activity.Content = new Literal("<h1>Hello World!</h1><p>Elsa says hi :)</p>");
|
||||
activity.Content = new LiteralExpression("<h1>Hello World!</h1><p>Elsa says hi :)</p>");
|
||||
activity.ContentType = "text/html";
|
||||
activity.StatusCode = HttpStatusCode.OK;
|
||||
activity.ResponseHeaders = new Literal("X-Powered-By=Elsa Workflows");
|
||||
activity.ResponseHeaders = new LiteralExpression("X-Powered-By=Elsa Workflows");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Sample07
|
|||
.Then<SendEmail>(
|
||||
activity =>
|
||||
{
|
||||
activity.From = new Literal("approval@acme.com");
|
||||
activity.From = new LiteralExpression("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 Literal("<h1>Request for Approval Sent</h1><p>Your document has been received and will be reviewed shortly.</p>");
|
||||
activity.Content = new LiteralExpression("<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 Literal("X-Powered-By=Elsa Workflows");
|
||||
activity.ResponseHeaders = new LiteralExpression("X-Powered-By=Elsa Workflows");
|
||||
}
|
||||
)
|
||||
.Then<Fork>(
|
||||
|
|
@ -60,12 +60,12 @@ namespace Sample07
|
|||
{
|
||||
fork
|
||||
.When("Approve")
|
||||
.Then<Signaled>(activity => activity.Signal = new Literal("approve"))
|
||||
.Then<Signaled>(activity => activity.Signal = new LiteralExpression("approve"))
|
||||
.Then("join-signals");
|
||||
|
||||
fork
|
||||
.When("Reject")
|
||||
.Then<Signaled>(activity => activity.Signal = new Literal("reject"))
|
||||
.Then<Signaled>(activity => activity.Signal = new LiteralExpression("reject"))
|
||||
.Then("join-signals");
|
||||
}
|
||||
)
|
||||
|
|
@ -78,7 +78,7 @@ namespace Sample07
|
|||
.Then<SendEmail>(
|
||||
activity =>
|
||||
{
|
||||
activity.From = new Literal("approval@acme.com");
|
||||
activity.From = new LiteralExpression("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 Literal("approval@acme.com");
|
||||
activity.From = new LiteralExpression("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.`");
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace Sample08.Workflows
|
|||
.Then<HttpResponseAction>(
|
||||
activity =>
|
||||
{
|
||||
activity.Content = new Literal("<h1>Order Received</h1><p>Your order has been received. Waiting for shipment.</p>");
|
||||
activity.Content = new LiteralExpression("<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 Literal("shipment@acme.com");
|
||||
activity.From = new LiteralExpression("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>(
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Sample08.Workflows
|
|||
activity.Expression = new JavaScriptExpression<object>("lastResult().Order");
|
||||
}
|
||||
)
|
||||
.Then<TimerEvent>(activity => activity.TimeoutExpression = new PlainTextExpression<TimeSpan>("00:00:05"))
|
||||
.Then<TimerEvent>(activity => activity.TimeoutExpression = new LiteralExpression<TimeSpan>("00:00:05"))
|
||||
.Then<SendMassTransitMessage>(activity =>
|
||||
{
|
||||
activity.Message = new JavaScriptExpression<OrderShipped>("return {order: order}");
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Sample10
|
|||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new Literal("Hello World!"));
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new LiteralExpression("Hello World!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,9 +12,9 @@ namespace Sample11
|
|||
{
|
||||
builder
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new JavaScriptExpression<string>("`Workflow started with correlation ID \"${correlationId()}\".`"))
|
||||
.Then<Signaled>(activity => activity.Signal = new Literal("Proceed"))
|
||||
.Then<Signaled>(activity => activity.Signal = new LiteralExpression("Proceed"))
|
||||
.Then<WriteLine>(activity => activity.TextExpression = new JavaScriptExpression<string>("`Signal received for workflow with correlation ID: \"${correlationId()}\"`"))
|
||||
.Then<WriteLine>(activity => activity.TextExpression = new Literal("Workflow finished."));
|
||||
.Then<WriteLine>(activity => activity.TextExpression = new LiteralExpression("Workflow finished."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,27 +11,27 @@ namespace Sample12
|
|||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new Literal("Workflow started. Waiting for user action."))
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new LiteralExpression("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 Literal("Great! Your work has been accepted."))
|
||||
.Then<WriteLine>(activity => activity.TextExpression = new LiteralExpression("Great! Your work has been accepted."))
|
||||
.Then("Exit");
|
||||
|
||||
userTask.When("Reject")
|
||||
.Then<WriteLine>(activity => activity.TextExpression = new Literal("Sorry! Your work has been rejected."))
|
||||
.Then<WriteLine>(activity => activity.TextExpression = new LiteralExpression("Sorry! Your work has been rejected."))
|
||||
.Then("Exit");
|
||||
|
||||
userTask.When("Needs Work")
|
||||
.Then<WriteLine>(activity => activity.TextExpression = new Literal("So close! Your work needs a little bit more work."))
|
||||
.Then<WriteLine>(activity => activity.TextExpression = new LiteralExpression("So close! Your work needs a little bit more work."))
|
||||
.Then("WaitUser");
|
||||
},
|
||||
"WaitUser"
|
||||
)
|
||||
.Add<WriteLine>(activity => activity.TextExpression = new Literal("Workflow finished."), "Exit");
|
||||
.Add<WriteLine>(activity => activity.TextExpression = new LiteralExpression("Workflow finished."), "Exit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace Sample13
|
|||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new Literal("Hi! What's your name?"))
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new LiteralExpression("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")
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Sample14
|
|||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new Literal("Hello World!"));
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new LiteralExpression("Hello World!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace Sample15
|
|||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new Literal("Hello World!"));
|
||||
.StartWith<WriteLine>(activity => activity.TextExpression = new LiteralExpression("Hello World!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ namespace Elsa.Activities.Console.Activities
|
|||
|
||||
public WorkflowExpression<string> TextExpression
|
||||
{
|
||||
get => GetState(() => PlainTextEvaluator.Expression<string>(null));
|
||||
get => GetState(() => LiteralEvaluator.Expression<string>(null));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,25 +29,25 @@ namespace Elsa.Activities.Email.Activities
|
|||
|
||||
public WorkflowExpression<string> From
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
public WorkflowExpression<string> To
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
public WorkflowExpression<string> Subject
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
public WorkflowExpression<string> Body
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ namespace Elsa.Activities.Http.Activities
|
|||
var url = GetState<string>();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(url) && Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out var uri))
|
||||
return new WorkflowExpression<Uri>(PlainTextEvaluator.SyntaxName, uri.ToString());
|
||||
return new WorkflowExpression<Uri>(LiteralEvaluator.SyntaxName, uri.ToString());
|
||||
|
||||
return new WorkflowExpression<Uri>(PlainTextEvaluator.SyntaxName, "");
|
||||
return new WorkflowExpression<Uri>(LiteralEvaluator.SyntaxName, "");
|
||||
}
|
||||
set => SetState(value.ToString());
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ namespace Elsa.Activities.Http.Activities
|
|||
/// </summary>
|
||||
public WorkflowExpression<string> Body
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ namespace Elsa.Activities.Http.Activities
|
|||
/// </summary>
|
||||
public WorkflowExpression<string> ContentType
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ namespace Elsa.Activities.Http.Activities
|
|||
/// </summary>
|
||||
public WorkflowExpression<string> RequestHeaders
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Elsa.Activities.Http.Activities
|
|||
/// </summary>
|
||||
public WorkflowExpression<string> Content
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ namespace Elsa.Activities.Http.Activities
|
|||
/// </summary>
|
||||
public WorkflowExpression<string> ResponseHeaders
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Elsa.Activities.Timers.Activities
|
|||
|
||||
public WorkflowExpression<string> CronExpression
|
||||
{
|
||||
get => GetState(() => new Literal("* * * * *"));
|
||||
get => GetState(() => new LiteralExpression("* * * * *"));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Elsa.Activities.Timers.Activities
|
|||
|
||||
public WorkflowExpression<TimeSpan> TimeoutExpression
|
||||
{
|
||||
get => GetState(() => new PlainTextExpression<TimeSpan>("00:01:00"));
|
||||
get => GetState(() => new LiteralExpression<TimeSpan>("00:01:00"));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Elsa.Activities.Workflows
|
|||
|
||||
public WorkflowExpression<string> CorrelationId
|
||||
{
|
||||
get => GetState(() => new WorkflowExpression<string>(PlainTextEvaluator.SyntaxName, ""));
|
||||
get => GetState(() => new WorkflowExpression<string>(LiteralEvaluator.SyntaxName, ""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Elsa.Activities.Workflows
|
|||
|
||||
public WorkflowExpression<string> ActivityType
|
||||
{
|
||||
get => GetState(() => new Literal(""));
|
||||
get => GetState(() => new LiteralExpression(""));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ namespace Elsa.Activities.Workflows
|
|||
|
||||
public WorkflowExpression<string> CorrelationId
|
||||
{
|
||||
get => GetState(() => new Literal(Guid.NewGuid().ToString()));
|
||||
get => GetState(() => new LiteralExpression(Guid.NewGuid().ToString()));
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +1,28 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Expressions
|
||||
{
|
||||
public class PlainTextEvaluator : IExpressionEvaluator
|
||||
{
|
||||
public static WorkflowExpression<T> Expression<T>(string expression)
|
||||
{
|
||||
return new WorkflowExpression<T>(SyntaxName, expression);
|
||||
}
|
||||
|
||||
public const string SyntaxName = "PlainText";
|
||||
public string Syntax => SyntaxName;
|
||||
|
||||
public Task<object> EvaluateAsync(string expression, Type type, WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(expression))
|
||||
return Task.FromResult(default(object));
|
||||
|
||||
return Task.FromResult(expression.Parse(type));
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Expressions
|
||||
{
|
||||
public class LiteralEvaluator : IExpressionEvaluator
|
||||
{
|
||||
public static WorkflowExpression<T> Expression<T>(string expression)
|
||||
{
|
||||
return new WorkflowExpression<T>(SyntaxName, expression);
|
||||
}
|
||||
|
||||
public const string SyntaxName = "PlainText";
|
||||
public string Syntax => SyntaxName;
|
||||
|
||||
public Task<object> EvaluateAsync(string expression, Type type, WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(expression))
|
||||
return Task.FromResult(default(object));
|
||||
|
||||
return Task.FromResult(expression.Parse(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/core/Elsa.Core/Expressions/LiteralExpression.cs
Normal file
16
src/core/Elsa.Core/Expressions/LiteralExpression.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
namespace Elsa.Expressions
|
||||
{
|
||||
public class LiteralExpression<T> : WorkflowExpression<T>
|
||||
{
|
||||
public LiteralExpression(string expression) : base(LiteralEvaluator.SyntaxName, expression)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class LiteralExpression : LiteralExpression<string>
|
||||
{
|
||||
public LiteralExpression(string expression) : base(expression)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ namespace Elsa.Extensions
|
|||
.TryAddProvider<ITokenFormatter, JsonTokenFormatter>(ServiceLifetime.Singleton)
|
||||
.TryAddProvider<ITokenFormatter, YamlTokenFormatter>(ServiceLifetime.Singleton)
|
||||
.TryAddProvider<ITokenFormatter, XmlTokenFormatter>(ServiceLifetime.Singleton)
|
||||
.TryAddProvider<IExpressionEvaluator, PlainTextEvaluator>(ServiceLifetime.Singleton)
|
||||
.TryAddProvider<IExpressionEvaluator, LiteralEvaluator>(ServiceLifetime.Singleton)
|
||||
.TryAddProvider<IExpressionEvaluator, JavaScriptEvaluator>(ServiceLifetime.Singleton)
|
||||
.AddSingleton<IScriptEngineConfigurator, CommonScriptEngineConfigurator>()
|
||||
.AddSingleton<IScriptEngineConfigurator, DateTimeScriptEngineConfigurator>()
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Elsa.Dashboard.Web
|
|||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddMvc(options => options.Conventions.Add(new AddLocalhostFilterConvention()))
|
||||
.AddMvc(/*options => options.Conventions.Add(new AddLocalhostFilterConvention())*/)
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Latest)
|
||||
.AddRazorOptions(options =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<p>Welcome to Elsa Dashboard!</p>
|
||||
<p>Use the menu on the left to navigate to manage all the things.</p>
|
||||
<p>Use the menu on the left to manage all the things.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Elsa.Dashboard.Options;
|
|||
using Elsa.Dashboard.Services;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Mapping;
|
||||
using Elsa.Persistence.Memory;
|
||||
using Elsa.Runtime;
|
||||
using Elsa.Serialization;
|
||||
using Elsa.Serialization.Formatters;
|
||||
|
|
@ -27,6 +28,8 @@ namespace Elsa.Dashboard.Extensions
|
|||
|
||||
services
|
||||
.AddTaskExecutingServer()
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddSingleton<IIdGenerator, IdGenerator>()
|
||||
.AddSingleton<IWorkflowSerializerProvider, WorkflowSerializerProvider>()
|
||||
.AddSingleton<IWorkflowSerializer, WorkflowSerializer>()
|
||||
|
|
|
|||
Loading…
Reference in a new issue