Exemplo n.º 1
0
        private void RegisterKnownUnit(KnownUnit unit)
        {
            units.Add(Tuple.Create(unit.Factor, unit.Dimension), unit);
            unitsBySymbol.Add(unit.Symbol, unit);

            if (unit.Factor.Equals(1))
            {
                this.coherentUnits.Add(unit.Dimension, unit);
            }
        }
Exemplo n.º 2
0
        private void EnsureUnitIsNotRegistered(KnownUnit unit)
        {
            if (this.units.Values.Any(u => u.Symbol == unit.Symbol))
            {
                throw new InvalidOperationException(Messages.UnitSymbolAlreadyKnown.FormatWith(unit.Symbol));
            }

            KnownUnit collision;

            if (this.units.TryGetValue(Tuple.Create(unit.Factor, unit.Dimension), out collision))
            {
                throw new InvalidOperationException(Messages.UnitAlreadyKnown.FormatWith(unit, collision));
            }
        }
Exemplo n.º 3
0
        private void EnsureUnitIsNotRegistered(KnownUnit unit)
        {
            if (this.units.Values.Any(u => u.Symbol == unit.Symbol))
            {
                throw new InvalidOperationException(Messages.UnitSymbolAlreadyKnown.FormatWith(unit.Symbol));
            }

            KnownUnit collision;

            if (this.units.TryGetValue(Tuple.Create(unit.Factor, unit.Dimension), out collision))
            {
                throw new InvalidOperationException(Messages.UnitAlreadyKnown.FormatWith(unit, collision));
            }
        }
Exemplo n.º 4
0
        private void RegisterKnownUnit(KnownUnit unit)
        {
            units.Add(Tuple.Create(unit.Factor, unit.Dimension), unit);
            unitsBySymbol.Add(unit.Symbol, unit);

            if (unit.Factor.Equals(1))
            {
                this.coherentUnits.Add(unit.Dimension, unit);
            }
        }