Пример #1
0
 public DerivedUnit(BaseUnit baseUnit, MetricPrefix prefix, double exponent)
 {
     _name     = null;
     _symbol   = null;
     _uiSymbol = null;
     Dimension = getExpression(baseUnit, prefix, exponent);
     IsNamed   = false;
 }
Пример #2
0
 public DerivedUnit(string name, string symbol, BaseUnit baseUnit, MetricPrefix prefix, double exponent)
 {
     _name     = name ?? throw new ArgumentNullException(nameof(name));
     _symbol   = symbol ?? throw new ArgumentNullException(nameof(symbol));
     _uiSymbol = null;
     Dimension = getExpression(baseUnit, prefix, exponent);
     IsNamed   = true;
 }
Пример #3
0
 private static bool tryParseByFullName(string uiSymbol, out MetricPrefix result)
 {
     result = MetricSystemManager.GetAllMetricPrefixes().FirstOrDefault(u => u.UISymbol == uiSymbol);
     if (result == default)
     {
         return(false);
     }
     return(true);
 }
Пример #4
0
        private static bool tryParseByName(string name, out MetricPrefix result)
        {
            result = MetricSystemManager.GetAllMetricPrefixes().FirstOrDefault(q => q.Name == name);
            if (result == null)
            {
                return(false);
            }

            return(true);
        }
Пример #5
0
        private static bool tryParseBySymbol(string symbol, out MetricPrefix result)
        {
            result = MetricSystemManager.GetAllMetricPrefixes().FirstOrDefault(q => q.Symbol == symbol);
            if (result == null)
            {
                return(false);
            }

            return(true);
        }
Пример #6
0
 internal void RemovePrefix(MetricPrefix metricPrefix)
 => prefixes.Remove(metricPrefix);
Пример #7
0
 internal void AddPrefix(MetricPrefix metricPrefix)
 => prefixes.Add(metricPrefix);
Пример #8
0
 private static DerivedUnitDimension generateDimensionFromBaseUnit(BaseUnit baseUnit, MetricPrefix prefix, double exponent) =>
Пример #9
0
 private static DerivedUnit multiplyPrefixByBaseUnit(MetricPrefix a, BaseUnit b)
 => multiplyBaseUnitByPrefix(b, a);
Пример #10
0
 private static DerivedUnit multiplyBaseUnitByPrefix(BaseUnit a, MetricPrefix b)
 => new DerivedUnit(a, b, 1);
Пример #11
0
 private DerivedUnitDimension getExpression(BaseUnit baseUnit, MetricPrefix prefix, double exponent) =>
Пример #12
0
 public static bool TryParse(string value, out MetricPrefix result) => tryParseByName(value, out result) ||
 tryParseByFullName(value, out result);
 public DerivedUnitDimensionMember(Unit baseUnit, MetricPrefix prefix, double exponent)
 {
     BaseUnit = baseUnit ?? throw new ArgumentNullException(nameof(baseUnit));
     Prefix   = prefix;
     Exponent = exponent;
 }