示例#1
0
        public IDimension GetOrAddRHSDimensionFor(IDimension dimension)
        {
            var dimensionName = rhsDimensionName(dimension);

            if (Has(dimensionName))
            {
                return(Dimension(dimensionName));
            }

            var unitName = rhsDefaultUnitName(dimension);

            // RHS is per Time hence -1
            var rhsDimensionRepresentation = new BaseDimensionRepresentation(dimension.BaseRepresentation);

            rhsDimensionRepresentation.TimeExponent -= 1;

            var rhsDimension           = new Dimension(rhsDimensionRepresentation, dimensionName, unitName);
            var equivalentRHSDimension = findFirstEquivalentDimension(rhsDimension, unitName);

            if (equivalentRHSDimension != null)
            {
                return(equivalentRHSDimension);
            }

            // Equivalent dimensions does noo exist. We add it and return it
            AddDimension(rhsDimension);
            return(rhsDimension);
        }
示例#2
0
 public Dimension(BaseDimensionRepresentation baseRepresentation, string dimensionName, string baseUnitName) : this()
 {
     _baseRepresentation = baseRepresentation;
     Name     = dimensionName;
     BaseUnit = new Unit(baseUnitName, 1.0, 0.0);
     _units.Add(BaseUnit);
 }
示例#3
0
 public Dimension(BaseDimensionRepresentation baseRepresentation, string dimensionName, string baseUnitName)
 {
     BaseRepresentation = baseRepresentation;
     Name     = dimensionName;
     BaseUnit = new Unit(baseUnitName, 1f, 0f);
     _units.Add(BaseUnit);
 }
示例#4
0
 public BaseDimensionRepresentation(BaseDimensionRepresentation baseDimensionRepresentation)
 {
     LengthExponent            = baseDimensionRepresentation.LengthExponent;
     MassExponent              = baseDimensionRepresentation.MassExponent;
     TimeExponent              = baseDimensionRepresentation.TimeExponent;
     ElectricCurrentExponent   = baseDimensionRepresentation.ElectricCurrentExponent;
     TemperatureExponent       = baseDimensionRepresentation.TemperatureExponent;
     AmountExponent            = baseDimensionRepresentation.AmountExponent;
     LuminousIntensityExponent = baseDimensionRepresentation.LuminousIntensityExponent;
 }
示例#5
0
        public BaseDimensionRepresentation DividedBy(BaseDimensionRepresentation other)
        {
            var exponents = new double[BASE_DIMENSIONS];

            foreach (var baseDimension in Enum.GetValues(typeof(BaseDimension)))
            {
                var i = (int)baseDimension;
                exponents[i] = _exponents[i] - other._exponents[i];
            }
            return(new BaseDimensionRepresentation(exponents));
        }
示例#6
0
        public IDimension AddDimension(BaseDimensionRepresentation baseRepresentation, string dimensionName, string baseUnitName)
        {
            if (Has(dimensionName))
            {
                throw new NotUniqueIdException(dimensionName);
            }

            var dimension = new Dimension(baseRepresentation, dimensionName, baseUnitName);

            _dimensions.Add(dimension.Name, dimension);
            return(dimension);
        }
示例#7
0
        protected bool Equals(BaseDimensionRepresentation other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(EnumHelper.AllValuesFor <BaseDimension>().All(x => Exponent(x) == other.Exponent(x)));
        }