14 private readonly
Unit unit;
43 if (
Operand.AssociatedObjectValue is
double D)
48 if (
Unit.
TryConvert(M.Magnitude, M.Unit,
this.unit, out
double Magnitude) &&
51 return new Measurement(Magnitude, this.unit, Error);
54 throw new ScriptRuntimeException(
"Unable to convert from " + M.Unit.ToString() +
" to " +
this.unit.ToString() +
".",
this);
Script runtime exception.
Class managing a script expression.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
int Start
Start position in script expression.
ScriptNode Operand
Operand.
Base class for unary scalar operators.
PhysicalQuantity ToPhysicalQuantity()
Converts underlying object to a physical quantity.
double Magnitude
Magnitude
SetUnit(ScriptNode Operand, Unit Unit, int Start, int Length, Expression Expression)
Sets a physical unit
override IElement EvaluateScalar(IElement Operand, Variables Variables)
Evaluates the operator on scalar operands.
static bool TryConvert(double From, Unit FromUnit, Unit ToUnit, out double To)
Tries to convert a magnitude in one unit to a magnitude in another.
override string ToString()
Basic interface for all types of elements.
Interface for objects that can be represented as a physical quantity.