C# Class LitDev.LDUnits

Mostra file Open project: litdev1/LitDev

Public Methods

Method Description
AddBaseUnit ( Primitive dimension, Primitive name ) : void

Add a base unit to the system.

AddConstant ( Primitive description, Primitive name, Primitive value ) : void

Add a dimensionless constant to the system.

AddDerivedUnit ( Primitive description, Primitive name, Primitive units, Primitive add ) : void

Add a derived unit to the system.

Convert ( Primitive value, Primitive fromUnit, Primitive toUnit ) : Primitive

Convert a value from one unit to another.

Export ( ) : void

Export the current unit system to a file (units.txt in the current program folder).

GetBaseUnits ( ) : Primitive

Get a list of current base units.

GetConstants ( ) : Primitive

Get a list of current constants.

GetDerivedUnits ( ) : Primitive

Get a list of current derived units.

GetDimensions ( Primitive unit ) : Primitive

Get an array of dimensions for a unit.

GetErrors ( ) : Primitive

Get an array of error messages if a Convert fails or conflicts are found for added units or constants.

GetPrefixes ( ) : Primitive

Get a list of current prefixes.

Import ( ) : void

Import a unit system from a file (units.txt in the current program folder).

Method Details

AddBaseUnit() public static method

Add a base unit to the system.
public static AddBaseUnit ( Primitive dimension, Primitive name ) : void
dimension Primitive The base unit dimension (e.g. TEMPERATURE).
name Primitive The unit name (be careful it doesn't confict with existing unit names).
return void

AddConstant() public static method

Add a dimensionless constant to the system.
public static AddConstant ( Primitive description, Primitive name, Primitive value ) : void
description Primitive An optional long name or description of the constant.
name Primitive The constant name (be careful it doesn't confict with existing constant names).
value Primitive The derived constant value.
return void

AddDerivedUnit() public static method

Add a derived unit to the system.
public static AddDerivedUnit ( Primitive description, Primitive name, Primitive units, Primitive add ) : void
description Primitive An optional long name or description of the derived unit.
name Primitive The unit name (be careful it doesn't confict with existing unit names).
units Primitive The derived unit definition.
add Primitive An optional addition term.
return void

Convert() public static method

Convert a value from one unit to another.
public static Convert ( Primitive value, Primitive fromUnit, Primitive toUnit ) : Primitive
value Primitive The value to convert.
fromUnit Primitive The units to convert from.
toUnit Primitive The units to convert to.
return Primitive

Export() public static method

Export the current unit system to a file (units.txt in the current program folder).
public static Export ( ) : void
return void

GetBaseUnits() public static method

Get a list of current base units.
public static GetBaseUnits ( ) : Primitive
return Primitive

GetConstants() public static method

Get a list of current constants.
public static GetConstants ( ) : Primitive
return Primitive

GetDerivedUnits() public static method

Get a list of current derived units.
public static GetDerivedUnits ( ) : Primitive
return Primitive

GetDimensions() public static method

Get an array of dimensions for a unit.
public static GetDimensions ( Primitive unit ) : Primitive
unit Primitive The unit to get dimensins of.
return Primitive

GetErrors() public static method

Get an array of error messages if a Convert fails or conflicts are found for added units or constants.
public static GetErrors ( ) : Primitive
return Primitive

GetPrefixes() public static method

Get a list of current prefixes.
public static GetPrefixes ( ) : Primitive
return Primitive

Import() public static method

Import a unit system from a file (units.txt in the current program folder).
public static Import ( ) : void
return void