Table of Contents

Class PrefixExpressionExtensions

Namespace
Albatross.Expression.Nodes
Assembly
Albatross.Expression.dll

Extension methods for IPrefixExpression that provide convenient operand access and validation. Simplifies getting values from prefix expression operands with type conversion and error handling.

public static class PrefixExpressionExtensions
Inheritance
PrefixExpressionExtensions
Inherited Members

Methods

GetRequiredStringValue(IPrefixExpression, int, Func<string, object>)

Gets a required non-empty string value of an operand at the specified index. Trims whitespace and throws an exception if the result is empty.

public static string GetRequiredStringValue(this IPrefixExpression expression, int index, Func<string, object> context)

Parameters

expression IPrefixExpression

The prefix expression containing the operands.

index int

The zero-based index of the operand.

context Func<string, object>

Function to resolve variable values during evaluation.

Returns

string

The trimmed string value of the operand.

Exceptions

OperandException

Thrown when the index is out of range or the string value is empty after trimming.

GetRequiredStringValue(List<object>, int)

Gets a required non-empty string value from a list at the specified index. Trims whitespace and throws an exception if the result is empty.

public static string GetRequiredStringValue(this List<object> list, int index)

Parameters

list List<object>

The list of values.

index int

The zero-based index of the value.

Returns

string

The trimmed string value at the specified index.

Exceptions

OperandException

Thrown when the string value is empty after trimming.

ArgumentOutOfRangeException

Thrown when the index is out of range.

GetRequiredStringValueAsync(IPrefixExpression, int, Func<string, Task<object>>)

Asynchronously gets a required non-empty string value of an operand at the specified index. Trims whitespace and throws an exception if the result is empty.

public static Task<string> GetRequiredStringValueAsync(this IPrefixExpression expression, int index, Func<string, Task<object>> context)

Parameters

expression IPrefixExpression

The prefix expression containing the operands.

index int

The zero-based index of the operand.

context Func<string, Task<object>>

Async function to resolve variable values during evaluation.

Returns

Task<string>

A task containing the trimmed string value of the operand.

Exceptions

OperandException

Thrown when the index is out of range or the string value is empty after trimming.

GetStringValue(IPrefixExpression, int, Func<string, object>)

Gets the string representation of an operand value at the specified index.

public static string GetStringValue(this IPrefixExpression expression, int index, Func<string, object> context)

Parameters

expression IPrefixExpression

The prefix expression containing the operands.

index int

The zero-based index of the operand.

context Func<string, object>

Function to resolve variable values during evaluation.

Returns

string

The string representation of the operand value.

Exceptions

OperandException

Thrown when the index is out of range.

GetStringValueAsync(IPrefixExpression, int, Func<string, Task<object>>)

Asynchronously gets the string representation of an operand value at the specified index.

public static Task<string> GetStringValueAsync(this IPrefixExpression expression, int index, Func<string, Task<object>> context)

Parameters

expression IPrefixExpression

The prefix expression containing the operands.

index int

The zero-based index of the operand.

context Func<string, Task<object>>

Async function to resolve variable values during evaluation.

Returns

Task<string>

A task containing the string representation of the operand value.

Exceptions

OperandException

Thrown when the index is out of range.

GetValue(IPrefixExpression, int, Func<string, object>)

Gets the evaluated value of an operand at the specified index.

public static object GetValue(this IPrefixExpression expression, int index, Func<string, object> context)

Parameters

expression IPrefixExpression

The prefix expression containing the operands.

index int

The zero-based index of the operand.

context Func<string, object>

Function to resolve variable values during evaluation.

Returns

object

The evaluated value of the operand.

Exceptions

OperandException

Thrown when the index is out of range.

GetValueAsync(IPrefixExpression, int, Func<string, Task<object>>)

Asynchronously gets the evaluated value of an operand at the specified index.

public static Task<object> GetValueAsync(this IPrefixExpression expression, int index, Func<string, Task<object>> context)

Parameters

expression IPrefixExpression

The prefix expression containing the operands.

index int

The zero-based index of the operand.

context Func<string, Task<object>>

Async function to resolve variable values during evaluation.

Returns

Task<object>

A task containing the evaluated value of the operand.

Exceptions

OperandException

Thrown when the index is out of range.

GetValues(IPrefixExpression, Func<string, object>)

Gets all operand values as a list by evaluating each operand.

public static List<object> GetValues(this IPrefixExpression expression, Func<string, object> context)

Parameters

expression IPrefixExpression

The prefix expression containing the operands.

context Func<string, object>

Function to resolve variable values during evaluation.

Returns

List<object>

A list containing the evaluated values of all operands.

GetValuesAsync(IPrefixExpression, Func<string, Task<object>>)

Asynchronously gets all operand values as a list by evaluating each operand.

public static Task<List<object>> GetValuesAsync(this IPrefixExpression expression, Func<string, Task<object>> context)

Parameters

expression IPrefixExpression

The prefix expression containing the operands.

context Func<string, Task<object>>

Async function to resolve variable values during evaluation.

Returns

Task<List<object>>

A task containing a list of evaluated values of all operands.