Class Expression<T>
- Namespace
- Acuit.Pinpoint.Workflows.Expressions
- Assembly
- Acuit.Pinpoint.Workflows.dll
A value source that gets its value by evaluating a C# expression.
public class Expression<T> : ValueSource<T>
Type Parameters
TThe value type, which should be compatible with the return value of the C# expression.
- Inheritance
-
ValueSource<T>Expression<T>
- Inherited Members
Remarks
Expressions require an IExpressionEnvironment service to be available in the provided ActivityContext.
Constructors
Expression()
Initializes a new instance of the Expression<T> class.
public Expression()
Expression(string)
Initializes a new instance of the Expression<T> class.
public Expression(string code)
Parameters
codestringThe C# expression.
Exceptions
- ArgumentNullException
codeis null.
Expression(string, string)
Initializes a new instance of the Expression<T> class.
public Expression(string code, string text)
Parameters
codestringThe C# expression.
textstringThe text to use when this instance is converted to a string via ToString().
Exceptions
- ArgumentNullException
codeis null.- ArgumentNullException
textis null.
Expression(string, string, IExpressionEnvironment)
Initializes a new instance of the Expression<T> class, immediately compiling the expression.
public Expression(string code, string text, IExpressionEnvironment expressionEnvironment)
Parameters
codestringThe C# expression.
textstringThe text to use when this instance is converted to a string via ToString().
expressionEnvironmentIExpressionEnvironmentThe expression environment.
Exceptions
- ArgumentNullException
codeis null.- ArgumentNullException
textis null.- ArgumentNullException
expressionEnvironmentis null.- ArgumentException
codeis an empty string.- Exception
There was an error compiling
code. Specific exceptions are not documented.
Properties
Code
Gets the C# expression, or an empty string if not set.
public string Code { get; }
Property Value
Methods
EvaluateAsync(ActivityContext, CancellationToken)
Evaluates the value.
public override Task<T> EvaluateAsync(ActivityContext context, CancellationToken cancellationToken = default)
Parameters
contextActivityContextThe activity context.
cancellationTokenCancellationTokenA token that can request cancelling the evaluation.
Returns
- Task<T>
A task that represents the asynchronous operation. The value of its Result property contains the resulting value.
Remarks
This will compile the C# expression in Code if it has not yet been compiled, at which time it requires an
IExpressionEnvironment service via context.
Exceptions
- ArgumentNullException
contextis null.- InvalidOperationException
Code has not been set.
- InvalidOperationException
There is no service of type IExpressionEnvironment.
- Exception
There was an error compiling Code. Specific exceptions are not documented.
- Exception
There was an error executing the compiled Code. Specific exceptions are not documented.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.