Table of Contents

Class UnaryExpression

Namespace
Albatross.Expression.Unary
Assembly
Albatross.Expression.dll

Base implementation for unary operation expressions that operate on a single operand.

public class UnaryExpression : IUnaryExpression, IExpression, IToken, IHasPrecedence
Inheritance
UnaryExpression
Implements
Derived
Inherited Members
Extension Methods

Constructors

UnaryExpression(string, int)

Initializes a new instance of the UnaryExpression class.

public UnaryExpression(string operatorOperator, int precedence)

Parameters

operatorOperator string

The operator symbol.

precedence int

The precedence level for this operation.

Properties

Operand

The operand that this unary operation applies to.

public IExpression? Operand { get; set; }

Property Value

IExpression

Operator

The operator symbol for this unary operation.

public string Operator { get; }

Property Value

string

Precedence

The precedence level of this operation for proper evaluation order.

public int Precedence { get; }

Property Value

int

RequiredOperand

Gets the required operand, throwing an exception if it's null.

public IExpression RequiredOperand { get; }

Property Value

IExpression

Token

The token representation, which is the same as the Operator.

public string Token { get; }

Property Value

string

Methods

Eval(Func<string, object>)

Evaluates the expression synchronously using the provided context function.

public object Eval(Func<string, object> context)

Parameters

context Func<string, object>

A function that resolves variable names to their values.

Returns

object

The result of evaluating the expression.

EvalAsync(Func<string, Task<object>>)

Evaluates the expression asynchronously using the provided context function.

public Task<object> EvalAsync(Func<string, Task<object>> context)

Parameters

context Func<string, Task<object>>

A function that asynchronously resolves variable names to their values.

Returns

Task<object>

A task containing the result of evaluating the expression.

Run(object)

protected virtual object Run(object operand)

Parameters

operand object

Returns

object

Text()

Returns the text representation of this token for display or serialization purposes.

public string Text()

Returns

string

A string representation of the token.