Plugin note
This functionality is contained within an expression evaluator plugin. As such, it is available only when the corresponding plugin is installed.
Plugin assembly
CSF.Zpt.ExpressionEvaluators.NotExpressions.dll
Plugin class
CSF.Zpt.ExpressionEvaluators.NotExpressions.NotExpressionEvaluator
Expression prefix
not:
TALES 'not' expressions
A not:
expression is immediately followed by another expression - indicating a value.
That following expression is evaluated as a completely independent expression in its own right, starting with
an optional prefix, or treated as a
path:
expression if it has no prefix.
Once the value of the expression following the not:
prefix has been determined, its value is
interpreted as a boolean using the method below. Finally, that boolean value is inverted (a logical not).
Special rules for boolean interpretation
The not:
expression has specific rules for interpreting values as
booleans; these rules differ from the normal boolean coercion rules.
The following rules are processed in the order listed:
- If the value cancels the action then it is interpreted as false.
-
If the value is a
null
reference, then it is interpreted as false. -
If the value is a
System.Boolean
then it is interpreted as its boolean value. - If the value is of any numeric type and equals zero, then it is interpreted as false.
-
If the value is
System.Collections.IEnumerable
then it is interpreted as true if it contains any items. Otherwise (if it is an empty collection) then it is interpreted as false. -
If the value is of a type which implements
CSF.Zpt.Tales.ITalesConvertible
then theAsBoolean()
method is called from the value and the result of that method is used as the boolean interpretation. - All other values (numeric values other than zero, all non-empty strings, all other value-type values, and all other non-null reference-type instances) are interpreted as true.