Added Workflows.Token token.

Fixes #6838
This commit is contained in:
Sipke Schoorstra
2016-04-26 16:23:13 +02:00
parent ebd731e70a
commit 6b72d498ae

View File

@@ -9,12 +9,14 @@ namespace Orchard.Workflows.Tokens {
public void Describe(DescribeContext context) {
context.For("Workflow", T("Workflow"), T("Workflow tokens."))
.Token("State:*", T("State:<workflowcontext path>"), T("The workflow context state to access. Workflow.State:MyData.MyProperty.SubProperty"))
.Token("Token:*", T("Token:<token name>"), T("The workflow context token to access. Workflow.Token:MyToken"))
;
}
public void Evaluate(EvaluateContext context) {
context.For<WorkflowContext>("Workflow")
.Token(token => token.StartsWith("State:", StringComparison.OrdinalIgnoreCase) ? token.Substring("State:".Length) : null, ParseState);
.Token(token => token.StartsWith("State:", StringComparison.OrdinalIgnoreCase) ? token.Substring("State:".Length) : null, ParseState)
.Token(token => token.StartsWith("Token:", StringComparison.OrdinalIgnoreCase) ? token.Substring("Token:".Length) : null, ParseToken);
}
/// <summary>
@@ -34,5 +36,12 @@ namespace Orchard.Workflows.Tokens {
return obj;
}
/// <summary>
/// Returns the specified token from the token dictionary stored as part of the workflow context.
/// </summary>
private object ParseToken(string tokenName, WorkflowContext workflowContext) {
return workflowContext.Tokens.ContainsKey(tokenName) ? workflowContext.Tokens[tokenName] : null;
}
}
}