Interface IEvaluatesExpression
An object which evaluates and returns the result of a TALES expression. This is the core interface for an "expression evaluator".
Namespace: ZptSharp.Expressions
Assembly: ZptSharp.Abstractions.dll
Syntax
public interface IEvaluatesExpression
Remarks
TALES - Template Attribute Language Expression Syntax - is an extensible language.
Expressions may be prefixed with a type designator such as expression_type:expression_body
,
where expression_type
indicates which expression evaluator should be used to handle the
expression body.
ZptSharp uses a registry of expression evaluators (and their type prefixes) such that prefixed expressions are automatically routed to their correct evaluator implementation. Additionally, the core logic ensures that the prefix is stripped from the expression before the evaluator receives it.
Methods
| Improve this Doc View SourceEvaluateExpressionAsync(String, ExpressionContext, CancellationToken)
Evaluates the expression asynchronously and returns the result.
Declaration
Task<object> EvaluateExpressionAsync(string expression, ExpressionContext context, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The expression string. |
ExpressionContext | context | The expression context. |
System.Threading.CancellationToken | cancellationToken | An optional cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | The expression result. |
Remarks
This method must decisively evaluate the expression, if an expression cannot be evaluated to a conclusive result then this method must throw EvaluationException or an exception derived from an evaluation exception. It is acceptable to return null from this method though, if that is the result of evaluating the expression.
Whilst the API of this method is asynchronous (returning a task), it will not be suitable
or appropriate for all implementations to act asynchronously.
Thus, implementors are not certain to honour the cancellationToken
if
it is used to cancel/abort evalaution early.
Implementors are encouraged to act asynchronously when it is appropriate to do so, but may
choose to act synchronously and return an already-completed task.
Note that any expression result might also be an AbortZptActionToken, which is a special value indicating that the current ZPT operation should be aborted.
Exceptions
Type | Condition |
---|---|
EvaluationException | Thrown if evaluating the expression fails. |
System.AggregateException | Thrown if evaluating the expression fails asynchronously. |