/// <summary>Checks if a unit already exists</summary> public static bool Contains(MeasureUnit unit) => Base.ContainsKey(unit.GetType().Name);
/// <summary>Returns a base measure unit for a given unit (if exists)</summary> public static MeasureUnit Get(MeasureUnit unit) => Contains(unit) ? Base[unit.GetType().Name] : null;
/// <summary>Amount of specified Measure Units (rounded as specified in Rounding)</summary> /// <param name="unit">Measure Unit</param> /// <exception cref="MeasureException">Thrown when Measure Units have different types</exception> public decimal AmountOf(MeasureUnit unit) => MeasureUnit.IsSubClassOf(unit) ? (Amount * MeasureUnit.AmountOf(unit)).Round(Rounding, Decimals) : throw new MeasureException(MeasureException.DIFFERENT_TYPES);