Ejemplo n.º 1
0
        public RelativeHumidity(double value, RelativeHumidityUnit unit)
        {
            if (unit == RelativeHumidityUnit.Undefined)
            {
                throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit));
            }

            _value = Guard.EnsureValidNumber(value, nameof(value));
            _unit  = unit;
        }
Ejemplo n.º 2
0
        public RelativeHumidity(double value, UnitSystem unitSystem)
        {
            if (unitSystem is null)
            {
                throw new ArgumentNullException(nameof(unitSystem));
            }

            var unitInfos     = Info.GetUnitInfosFor(unitSystem.BaseUnits);
            var firstUnitInfo = unitInfos.FirstOrDefault();

            _value = Guard.EnsureValidNumber(value, nameof(value));
            _unit  = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem));
        }
Ejemplo n.º 3
0
        public RelativeHumidity(double value, UnitSystem unitSystem)
        {
            if (unitSystem is null)
            {
                throw new ArgumentNullException(nameof(unitSystem));
            }

            _value = Guard.EnsureValidNumber(value, nameof(value));

            var defaultUnitInfo = unitSystem.GetDefaultUnitInfo(QuantityType) as UnitInfo <RelativeHumidityUnit>;

            _unit = defaultUnitInfo?.Value ?? throw new ArgumentException("No default unit was defined for the given UnitSystem.", nameof(unitSystem));
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Creates the quantity with a value of 0 in the base unit Percent.
 /// </summary>
 /// <remarks>
 ///     Windows Runtime Component requires a default constructor.
 /// </remarks>
 public RelativeHumidity()
 {
     _value = 0;
     _unit  = BaseUnit;
 }