Project Description

Simple .NET 4 library of types to represent various units of measure.

Currently 3 categories of measurement are supported: Length, Mass and Volume.

Each category exposes the following:

1. An archetype which can represent any unit of measure in the category.
2. Specific types to represent each specific unit of measure.
3. TypeDescriptors for each measurement type to support conversion.
4. A FormatProvider, responsible for producing and parsing text strings.
5. A resource file, containing localizable formatting representations.

The source code for the above types is entirely generated using T4 templates, which allow new categories and new units of measure to be implemented with just a single line of code.

Modifying string formatting and parsing

There are three points of access for modifying how formatted strings are produced:

1. Write custom format strings when callling the ToString method. This is the simplest means of changing the resultant strings.
2. Write your own FormatProvider class, and pass it as an argument to the ToString method.
3. Modify the resource file for the unit of measure.

The default ToString method always uses the format provider that is defined for the measurement category, and this format provider always uses resource strings to produce string values. The resource keys are always: