Class ValueSource
The base class for a value source.
[TypeConverter(typeof(ValueSourceTypeConverter))]
public abstract class ValueSource
- Inheritance
-
ValueSource
- Derived
-
ValueSource<T>
- Inherited Members
Methods
EvaluateAsObjectAsync(ActivityContext, CancellationToken)
Evaluates the value.
public abstract Task<object> EvaluateAsObjectAsync(ActivityContext context, CancellationToken cancellationToken = default)
Parameters
context
ActivityContextThe activity context.
cancellationToken
CancellationTokenA token that can request cancelling the evaluation.
Returns
- Task<object>
A task that represents the asynchronous operation. The value of its Result property contains the resulting value.
FromDelegate<T>(Func<ActivityContext, CancellationToken, Task<T>>)
Creates a ValueSource<T> that gets its value via an asynchronous delegate.
public static ValueSource<T> FromDelegate<T>(Func<ActivityContext, CancellationToken, Task<T>> evaluator)
Parameters
evaluator
Func<ActivityContext, CancellationToken, Task<T>>The asynchronous evaluator delegate.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
T
The value type.
Exceptions
- ArgumentNullException
evaluator
is null.
FromDelegate<T>(Func<ActivityContext, T>)
Creates a ValueSource<T> that gets its value from via synchronous delegate.
public static ValueSource<T> FromDelegate<T>(Func<ActivityContext, T> evaluator)
Parameters
evaluator
Func<ActivityContext, T>The synchronous evaluator delegate.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
T
The value type.
Exceptions
- ArgumentNullException
evaluator
is null.
FromExpression<T>(string)
Creates a ValueSource<T> that gets its value by executing a C# expression.
public static ValueSource<T> FromExpression<T>(string code)
Parameters
code
stringThe C# expression.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
T
The value type.
Exceptions
- ArgumentNullException
code
is null.- CompilationErrorException
code
could not be compiled.
FromValueSource<T, TSource>(ValueSource<TSource>)
Creates a ValueSource<T> that gets its value from another value source.
public static ValueSource<T> FromValueSource<T, TSource>(ValueSource<TSource> valueSource) where TSource : T
Parameters
valueSource
ValueSource<TSource>The other value source.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
T
The value type.
TSource
The value type of the other value source, which must be assignable to
T
.
Exceptions
- ArgumentNullException
valueSource
is null.
FromValue<T>(T)
Creates a ValueSource<T> that gets its value from a constant.
public static ValueSource<T> FromValue<T>(T value)
Parameters
value
TThe constant value.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
T
The value type.
Operators
implicit operator ValueSource(bool)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(bool value)
Parameters
value
boolThe constant value.
Returns
implicit operator ValueSource(byte)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(byte value)
Parameters
value
byteThe constant value.
Returns
implicit operator ValueSource(char)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(char value)
Parameters
value
charThe constant value.
Returns
implicit operator ValueSource(decimal)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(decimal value)
Parameters
value
decimalThe constant value.
Returns
implicit operator ValueSource(double)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(double value)
Parameters
value
doubleThe constant value.
Returns
implicit operator ValueSource(short)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(short value)
Parameters
value
shortThe constant value.
Returns
implicit operator ValueSource(int)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(int value)
Parameters
value
intThe constant value.
Returns
implicit operator ValueSource(long)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(long value)
Parameters
value
longThe constant value.
Returns
implicit operator ValueSource(bool?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(bool? value)
Parameters
value
bool?The constant value.
Returns
implicit operator ValueSource(byte?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(byte? value)
Parameters
value
byte?The constant value.
Returns
implicit operator ValueSource(char?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(char? value)
Parameters
value
char?The constant value.
Returns
implicit operator ValueSource(decimal?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(decimal? value)
Parameters
value
decimal?The constant value.
Returns
implicit operator ValueSource(double?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(double? value)
Parameters
value
double?The constant value.
Returns
implicit operator ValueSource(short?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(short? value)
Parameters
value
short?The constant value.
Returns
implicit operator ValueSource(int?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(int? value)
Parameters
value
int?The constant value.
Returns
implicit operator ValueSource(long?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(long? value)
Parameters
value
long?The constant value.
Returns
implicit operator ValueSource(sbyte?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(sbyte? value)
Parameters
value
sbyte?The constant value.
Returns
implicit operator ValueSource(float?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(float? value)
Parameters
value
float?The constant value.
Returns
implicit operator ValueSource(TimeSpan?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(TimeSpan? value)
Parameters
value
TimeSpan?The constant value.
Returns
implicit operator ValueSource(ushort?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(ushort? value)
Parameters
value
ushort?The constant value.
Returns
implicit operator ValueSource(uint?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(uint? value)
Parameters
value
uint?The constant value.
Returns
implicit operator ValueSource(ulong?)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(ulong? value)
Parameters
value
ulong?The constant value.
Returns
implicit operator ValueSource(sbyte)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(sbyte value)
Parameters
value
sbyteThe constant value.
Returns
implicit operator ValueSource(float)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(float value)
Parameters
value
floatThe constant value.
Returns
implicit operator ValueSource(string)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(string value)
Parameters
value
stringThe constant value.
Returns
implicit operator ValueSource(TimeSpan)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(TimeSpan value)
Parameters
value
TimeSpanThe constant value.
Returns
implicit operator ValueSource(ushort)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(ushort value)
Parameters
value
ushortThe constant value.
Returns
implicit operator ValueSource(uint)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(uint value)
Parameters
value
uintThe constant value.
Returns
implicit operator ValueSource(ulong)
Defines an implicit conversion of a constant value to a ValueSource.
public static implicit operator ValueSource(ulong value)
Parameters
value
ulongThe constant value.