public static string ToDisplayStringInShort(this VolumeUnit volumeUnit) { try { return(FactoryUnits.GetShortDisplayString(UnitsType.Volume, (int)volumeUnit)); } catch (InvalidOperationException) { throw new ArgumentOutOfRangeException(/*MSG0*/ "volumeUnit"); } }
public static string ToDisplayString(this AngularityUnit angularityUnit) { try { return(FactoryUnits.GetDisplayString(UnitsType.Angularity, (int)angularityUnit)); } catch (InvalidOperationException) { throw new ArgumentOutOfRangeException(/*MSG0*/ "angularityUnit"); } }
public static string ToDisplayString(this UnitlessUnit unitlessUnit) { try { return(FactoryUnits.GetDisplayString(UnitsType.Unitless, (int)unitlessUnit)); } catch (InvalidOperationException) { throw new ArgumentOutOfRangeException(/*MSG0*/ "unitlessUnit"); } }
public static string ToDisplayString(this CostRateUnit costRateUnit) { try { return(FactoryUnits.GetDisplayString(UnitsType.CostRate, (int)costRateUnit)); } catch (InvalidOperationException) { throw new ArgumentOutOfRangeException(/*MSG0*/ "costRateUnit"); } }
/// <summary> /// Get the UnitsType corresponding to the provided string /// </summary> /// <param name="unitsString"></param> /// <returns></returns> public static UnitsType GetUnitsType(string unitsString) { if (FactoryUnits.IsSpeedUnits(unitsString)) { return(UnitsType.Speed); } else if (FactoryUnits.IsTimeUnits(unitsString)) { return(UnitsType.Time); } else if (FactoryUnits.IsCostRateUnits(unitsString)) { return(UnitsType.CostRate); } else if (FactoryUnits.IsEnergyConsumptionRateUnits(unitsString)) { return(UnitsType.EnergyConsumptionRate); } else if (FactoryUnits.IsLengthUnit(unitsString)) { return(UnitsType.Length); } else if (FactoryUnits.IsAngularityUnit(unitsString)) { return(UnitsType.Angularity); } else if (FactoryUnits.IsUnitlessUnit(unitsString)) { return(UnitsType.Unitless); } else if (FactoryUnits.IsVolumeUnit(unitsString)) { return(UnitsType.Volume); } throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Resources.UnrecognizedUnits, unitsString)); }