Skip to content

Extending with Custom Units

Andreas Gullberg Larsen edited this page Feb 9, 2014 · 20 revisions

In 2.0 we added support for custom units. This means you get to reuse the T4 templates to generate unit classes and extend the UnitSystem class with abbreviations for your new units.

Custom Units vs Core Units

Generally we want to keep the core Units.NET library small, but at the same time cover units that are widely used in different fields of engineering. As a rule of thumb, if the unit is generally known to people outside the engineering or industry domain, then it should be included in the core library. Otherwise, consider creating an external unit or create a new issue for Units.NET to start a discussion.

Candidates for custom units:

Read more at the ThirdPartyExample repository. It uses T4 templates to generate code for the units of measurement Foo and Bar, it has its own tests and a sample app to illustrate how it can be used.