Model a quantity (such as length or acceleration) and its associated units. More...
Public Member Functions | |
void | AddUnit (Unit unit, bool isBaseUnit) |
Associate the specified unit with this quantity. More... | |
Unit | GetBaseUnit () |
Return the base unit of this quantity. More... | |
string | GetDescription () |
Return description of this quantity. More... | |
string | GetName () |
Return name of this quantity. More... | |
IList< Unit > | GetUnits () |
Return the units of this quantity. More... | |
Quantity (string name, string description) | |
Create a new quantity instance. More... | |
override string | ToString () |
Model a quantity (such as length or acceleration) and its associated units.
This class is thread-safe.
Quantity | ( | string | name, |
string | description | ||
) |
Create a new quantity instance.
name | Name of quantity, such as "length". Non-null. |
description | Optional description. Null if none provided. |
void AddUnit | ( | Unit | unit, |
bool | isBaseUnit | ||
) |
Associate the specified unit with this quantity.
unit | Unit to add. Non-null. |
isBaseUnit | True if this is the base unit, false otherwise. If more than one unit is added as base unit, the last one added will have this role. If no units are added as base unit, the first unit added will have this role. |
Unit GetBaseUnit | ( | ) |
Return the base unit of this quantity.
Equivalent to getUnits().get(0).
string GetDescription | ( | ) |
Return description of this quantity.
string GetName | ( | ) |
Return name of this quantity.
IList<Unit> GetUnits | ( | ) |
Return the units of this quantity.
The first unit in the list is always the base unit.