UoM .Net
Quantity Class Reference

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< UnitGetUnits ()
 Return the units of this quantity. More...
 
 Quantity (string name, string description)
 Create a new quantity instance. More...
 
override string ToString ()
 

Detailed Description

Model a quantity (such as length or acceleration) and its associated units.

This class is thread-safe.

Author
Petroware AS

Constructor & Destructor Documentation

Quantity ( string  name,
string  description 
)

Create a new quantity instance.

Parameters
nameName of quantity, such as "length". Non-null.
descriptionOptional description. Null if none provided.

Member Function Documentation

void AddUnit ( Unit  unit,
bool  isBaseUnit 
)

Associate the specified unit with this quantity.

Parameters
unitUnit to add. Non-null.
isBaseUnitTrue 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.
Returns

Unit GetBaseUnit ( )

Return the base unit of this quantity.

Equivalent to getUnits().get(0).

Returns
Base unit of this quantity, or null if no units has been added.
string GetDescription ( )

Return description of this quantity.

Returns
Description of this quantity. Null if none provided.
string GetName ( )

Return name of this quantity.

Returns
Name of this quantity. Never null.
IList<Unit> GetUnits ( )

Return the units of this quantity.

The first unit in the list is always the base unit.

Returns
Units of this quantity. Never null.

The documentation for this class was generated from the following file: