예제 #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);
        }
예제 #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);
                }
            }
        }
예제 #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);
                }
            }
        }
예제 #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);
        }
예제 #5
0
 public UnitSystem(string name, IUnitDialect dialect)
     : this(name, new UnitFactory(), dialect)
 {
 }
예제 #6
0
 public UnitSystem(string name, IUnitDialect dialect)
     : this(name, new UnitFactory(), dialect)
 {
 }