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
contextActivityContextThe activity context.
cancellationTokenCancellationTokenA 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
evaluatorFunc<ActivityContext, CancellationToken, Task<T>>The asynchronous evaluator delegate.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
TThe value type.
Exceptions
- ArgumentNullException
evaluatoris 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
evaluatorFunc<ActivityContext, T>The synchronous evaluator delegate.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
TThe value type.
Exceptions
- ArgumentNullException
evaluatoris 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
codestringThe C# expression.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
TThe value type.
Exceptions
- ArgumentNullException
codeis null.- CompilationErrorException
codecould 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
valueSourceValueSource<TSource>The other value source.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
TThe value type.
TSourceThe value type of the other value source, which must be assignable to
T.
Exceptions
- ArgumentNullException
valueSourceis null.
FromValue<T>(T)
Creates a ValueSource<T> that gets its value from a constant.
public static ValueSource<T> FromValue<T>(T value)
Parameters
valueTThe constant value.
Returns
- ValueSource<T>
A new ValueSource<T> instance.
Type Parameters
TThe 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
valueboolThe 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
valuebyteThe 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
valuecharThe 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
valuedecimalThe 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
valuedoubleThe 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
valueshortThe 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
valueintThe 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
valuelongThe 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
valuebool?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
valuebyte?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
valuechar?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
valuedecimal?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
valuedouble?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
valueshort?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
valueint?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
valuelong?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
valuesbyte?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
valuefloat?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
valueTimeSpan?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
valueushort?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
valueuint?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
valueulong?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
valuesbyteThe 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
valuefloatThe 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
valuestringThe 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
valueTimeSpanThe 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
valueushortThe 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
valueuintThe 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
valueulongThe constant value.