UnitParser code (.NET/C#)

Open source code of UnitParser
Similarly to what happens with all the other FlexibleParser parts, I wrote the whole C# (.NET 4.0) code of UnitParser completely from scratch. Its most recent version can be found in various places:The UnitParser code can be divided into the following main parts:
  • Instantiation
    . One of the defining features of UnitParser is the fact of using the same class (UnitP) for all the unit types. Such a configuration is only possible thanks to a set of readonly fields, which have to be defined at variable instantiation.
    All the UnitP class instantiation part is inside the files in the Contructors folder.
    To know more about this part of the code, take a look at the corresponding varocarbas.com section.
  • Hardcoding
    . The hardcoded information is an important part of any system dealing with units of measurement. UnitParser contains a relevant amount of up-to-date and high-quality hardcoded information. Examples: conversion factors, classifications, compound definitions, etc.
    Most of the UnitParser hardcoded information is stored in different files contained by the Keywords folder.
    To know more about this part of the code, take a look at the corresponding varocarbas.com section.
  • Unit parsing
    . Accurately parsing a wide variety of unit information is precisely the most distinctive feature of UnitParser. Unit parsing doesn't just involve recognising individual units, but also compounds and what this implies (e.g., extraction and simplification of constituent parts).
    All the unit parsing implementations are stored under the Parse folder.
    To know more about this part of the code, take a look at the corresponding varocarbas.com section.
  • Unit conversions
    . The conversion functionalities of UnitParser are also very powerful. Additionally to the typical individual unit conversion support, it performs auto-conversions when needed and fully supports conversions between random compounds (i.e., any set of supported units forming a supported type).
    The main unit conversion part is stored in Operations_Private_Conversions.cs.
    To know more about this part of the code, take a look at the corresponding varocarbas.com section.
  • Managed calculations
    . UnitParser is also characterised by its relevant numeric support. Managed calculations refer to all the code allowing UnitParser to perform arithmetic operations between any two variables/numbers.
    All the managed calculations are included in Operations_Private_Managed.cs.
    To know more about this part of the code, take a look at the corresponding varocarbas.com section.