Class ExternalContextValue<T>
- Namespace
- Albatross.Expression.Context
- Assembly
- Albatross.Expression.dll
Context value that delegates value retrieval to an external function. Computes the value dynamically based on the input context using the provided function.
public class ExternalContextValue<T> : IContextValue<T>
Type Parameters
TThe type of the root context object.
- Inheritance
-
ExternalContextValue<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
ExternalContextValue(string, Func<T, object>)
Initializes a new instance of the ExternalContextValue class with a value computation function.
public ExternalContextValue(string name, Func<T, object> func)
Parameters
namestringThe name of this context value.
funcFunc<T, object>The 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>)
Computes and returns the value by invoking the external function with the input context. Ignores the variable resolution function parameter since this value doesn't depend on other variables.
public object GetValue(T input, Func<string, T, object> _)
Parameters
inputTThe root context object passed to the computation function.
_Func<string, T, object>Function to resolve variables (ignored).
Returns
- object
The result of invoking the computation function with the input context.
GetValueAsync(T, Func<string, T, Task<object>>)
Asynchronously computes and returns the value by invoking the external function with the input context. Returns a completed task since the computation is synchronous.
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).