Beispiel #1
0
        private bool IsValidPrefixUnit(INameAndSymbol item)
        {
            if (this.settings.Prefixes.Any(p => item.Name.StartsWith(p.Name, StringComparison.OrdinalIgnoreCase)))
            {
                return(false);
            }

            var baseUnit = item as BaseUnit;

            if (baseUnit != null)
            {
                return(true);
            }

            var derivedUnit = item as DerivedUnit;

            if (derivedUnit != null)
            {
                IReadOnlyList <SymbolAndPower> symbolAndPowers;
                if (SymbolAndPowerReader.TryRead(derivedUnit.Symbol, out symbolAndPowers))
                {
                    return(symbolAndPowers.Count == 1 && symbolAndPowers[0].Power == 1);
                }

                return(false);
            }

            var factorConversion = item as FactorConversion;

            if (factorConversion != null)
            {
                return(true);
            }

            return(false);
        }
Beispiel #2
0
 private static PrefixConversion Create(INameAndSymbol nas, Prefix prefix)
 {
     return(new PrefixConversion(prefix.Name + nas.ParameterName.TrimStart('@'), prefix.Symbol + nas.Symbol, prefix.Name));
 }