-
-
Notifications
You must be signed in to change notification settings - Fork 4
IMathContext
Namespace: StringMath
Assembly: StringMath
Inheritance: IMathContext
Derived: MathContext
References: MathContext, MathExpr, MathExprExtensions, Precedence
Contract for math context.
public abstract interface IMathContext
The parent math context to inherit operators from.
public virtual IMathContext Parent { get; set; }
Property Value
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.
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.
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.
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.
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.
public virtual void RegisterBinary(string operatorName, Func<Double, Double, Double> operation, Precedence? precedence = null);
Parameters
operatorName
String
operation
Func<Double, Double, Double>
precedence
Precedence?
public virtual void RegisterUnary(string operatorName, Func<Double, Double> operation);
Parameters
operatorName
String
operation
Func<Double, Double>