Class AsyncExternalContextValue<T>
- Namespace
- Albatross.Expression.Context
- Assembly
- Albatross.Expression.dll
Context value that delegates value retrieval to an asynchronous external function. Computes the value dynamically and asynchronously based on the input context using the provided async function.
public class AsyncExternalContextValue<T> : IContextValue<T>
Type Parameters
TThe type of the root context object.
- Inheritance
-
AsyncExternalContextValue<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
AsyncExternalContextValue(string, Func<T, Task<object>>)
Initializes a new instance of the AsyncExternalContextValue class with an async value computation function.
public AsyncExternalContextValue(string name, Func<T, Task<object>> func)
Parameters
namestringThe name of this context value.
funcFunc<T, Task<object>>The async function that computes the value based on the input context.
Properties
Name
Gets the name of this context value.
public string Name { get; }
Property Value
Methods
GetValue(T, Func<string, T, object>)
Throws NotSupportedException as this context value only supports asynchronous evaluation. Use GetValueAsync instead for async-only context values.
public object GetValue(T input, Func<string, T, object> _)
Parameters
inputTThe root context object (ignored).
_Func<string, T, object>Function to resolve variables (ignored).
Returns
- object
Never returns normally.
Exceptions
- NotSupportedException
Always thrown since this context value requires asynchronous evaluation.
GetValueAsync(T, Func<string, T, Task<object>>)
Asynchronously computes and returns the value by invoking the external async function with the input context. Ignores the variable resolution function parameter since this value doesn't depend on other variables.
public Task<object> GetValueAsync(T input, Func<string, T, Task<object>> _)
Parameters
inputTThe root context object passed to the computation function.
_Func<string, T, Task<object>>Async function to resolve variables (ignored).