Table of Contents

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

T

The 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

name string

The name of this context value.

func Func<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

string

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

input T

The 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

input T

The root context object passed to the computation function.

_ Func<string, T, Task<object>>

Async function to resolve variables (ignored).

Returns

Task<object>

A task containing the result of the async computation function.