Example #1
0
 private UOM GetUOM(UOMCode code)
 {
     EnsureCacheIsLoaded();
     if (_uomCache.TryGetValue(code.Code, out UOM result))
     {
         return(result);
     }
     return(null);
 }
Example #2
0
        public double ConvertBetween(UOMCode source, UOMCode destination, double value)
        {
            UOM    uomSource      = GetUOM(source);
            UOM    uomDestination = GetUOM(destination);
            double newValue       = value;

            if (uomSource != null &&
                uomDestination != null &&
                uomSource != uomDestination)
            {
                newValue = ConvertFromBase(ConvertToBase(value, uomSource), uomDestination);
            }
            return(newValue);
        }