Beispiel #1
0
        internal UnitSystem(string name, IUnitFactory unitFactory, IUnitDialect dialect)
        {
            Check.Argument(name, nameof(name)).IsNotNull();
            Check.Argument(unitFactory, nameof(unitFactory)).IsNotNull();
            Check.Argument(dialect, nameof(dialect)).IsNotNull();

            this.unitFactory = unitFactory;
            this.dialect = dialect;
            this.Name = name;
            this.baseUnits = new Dictionary<Dimension, KnownUnit>();
            this.coherentUnits = new Dictionary<Dimension, Unit>();
            this.units = new Dictionary<Tuple<double, Dimension>, KnownUnit>();
            this.unitsBySymbol = new Dictionary<string, KnownUnit>();
            this.NoUnit = new DerivedUnit(this, 1, Dimension.DimensionLess);
        }
Beispiel #2
0
        public UnitInterpretor(IUnitSystem system, IUnitDialect dialect)
        {
            this.system = system;
            this.dialect = dialect;
            this.unitRegex = BuildUnitRegex();
            this.baseUnits = new List<KnownUnit>(this.system.BaseUnits);

            foreach (var unit in system)
            {
                if (unit.Symbol != unit.BaseSymbol)
                {
                    this.prefixedUnits.Add(unit.BaseSymbol, unit);
                }
            }
        }
Beispiel #3
0
        public UnitInterpretor(IUnitSystem system, IUnitDialect dialect)
        {
            this.system    = system;
            this.dialect   = dialect;
            this.unitRegex = BuildUnitRegex();
            this.baseUnits = new List <KnownUnit>(this.system.BaseUnits);

            foreach (var unit in system)
            {
                if (unit.Symbol != unit.BaseSymbol)
                {
                    this.prefixedUnits.Add(unit.BaseSymbol, unit);
                }
            }
        }
Beispiel #4
0
        internal UnitSystem(string name, IUnitFactory unitFactory, IUnitDialect dialect)
        {
            Check.Argument(name, nameof(name)).IsNotNull();
            Check.Argument(unitFactory, nameof(unitFactory)).IsNotNull();
            Check.Argument(dialect, nameof(dialect)).IsNotNull();

            this.unitFactory   = unitFactory;
            this.dialect       = dialect;
            this.Name          = name;
            this.baseUnits     = new Dictionary <Dimension, KnownUnit>();
            this.coherentUnits = new Dictionary <Dimension, Unit>();
            this.units         = new Dictionary <Tuple <double, Dimension>, KnownUnit>();
            this.unitsBySymbol = new Dictionary <string, KnownUnit>();
            this.NoUnit        = new DerivedUnit(this, 1, Dimension.DimensionLess);
        }
Beispiel #5
0
 public UnitSystem(string name, IUnitDialect dialect)
     : this(name, new UnitFactory(), dialect)
 {
 }
Beispiel #6
0
 public UnitSystem(string name, IUnitDialect dialect)
     : this(name, new UnitFactory(), dialect)
 {
 }