Skip to content
Miroiu Emanuel edited this page Oct 12, 2022 · 2 revisions

IMathContext Interface

Namespace: StringMath

Assembly: StringMath

Inheritance: IMathContext

Derived: MathContext

References: MathContext, MathExpr, MathExprExtensions, Precedence

Contract for math context.

public abstract interface IMathContext  

Properties

Parent

The parent math context to inherit operators from.

public virtual IMathContext Parent { get; set; }  

Property Value

IMathContext

Methods

EvaluateBinary(String, Double, Double)

Evaluates a binary operation.

public virtual double EvaluateBinary(string op, double a, double b);  

Parameters

op String: The operator.

a Double: Left value.

b Double: Right value.

Returns

Double: The result.

EvaluateUnary(String, Double)

Evaluates an unary operation.

public virtual double EvaluateUnary(string op, double a);  

Parameters

op String: The operator.

a Double: The value.

Returns

Double: The result.

GetBinaryPrecedence(String)

Returns the precedence of a binary operator. Unary operators have Precedence.Prefix precedence.

public virtual Precedence GetBinaryPrecedence(string operatorName);  

Parameters

operatorName String: The operator.

Returns

Precedence: A Precedence value.

IsBinary(String)

Tells whether an operator is binary.

public virtual bool IsBinary(string operatorName);  

Parameters

operatorName String: The operator.

Returns

Boolean: True if the operator is binary, false if it does not exist or it is unary.

IsUnary(String)

Tells whether an operator is unary.

public virtual bool IsUnary(string operatorName);  

Parameters

operatorName String: The operator.

Returns

Boolean: True if the operator is unary, false if it does not exist or it is binary.

RegisterBinary(String, Func<Double, Double, Double>, Precedence?)

public virtual void RegisterBinary(string operatorName, Func<Double, Double, Double> operation, Precedence? precedence = null);  

Parameters

operatorName String

operation Func<Double, Double, Double>

precedence Precedence?

RegisterUnary(String, Func<Double, Double>)

public virtual void RegisterUnary(string operatorName, Func<Double, Double> operation);  

Parameters

operatorName String

operation Func<Double, Double>