コード例 #1
0
ファイル: Humidity.g.cs プロジェクト: ilchdeveloper/UnitsNet
 public static bool TryParse(string?str, IFormatProvider?provider, out Humidity result)
 {
     return(QuantityParser.Default.TryParse <Humidity, HumidityUnit>(
                str,
                provider,
                From,
                out result));
 }
コード例 #2
0
ファイル: Humidity.g.cs プロジェクト: ilchdeveloper/UnitsNet
        /// <summary>
        ///     <para>
        ///     Compare equality to another Humidity within the given absolute or relative tolerance.
        ///     </para>
        ///     <para>
        ///     Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and
        ///     <paramref name="other"/> as a percentage of this quantity's value. <paramref name="other"/> will be converted into
        ///     this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of
        ///     this quantity's value to be considered equal.
        ///     <example>
        ///     In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm).
        ///     <code>
        ///     var a = Length.FromMeters(2.0);
        ///     var b = Length.FromInches(50.0);
        ///     a.Equals(b, 0.01, ComparisonType.Relative);
        ///     </code>
        ///     </example>
        ///     </para>
        ///     <para>
        ///     Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and
        ///     <paramref name="other"/> as a fixed number in this quantity's unit. <paramref name="other"/> will be converted into
        ///     this quantity's unit for comparison.
        ///     <example>
        ///     In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm).
        ///     <code>
        ///     var a = Length.FromMeters(2.0);
        ///     var b = Length.FromInches(50.0);
        ///     a.Equals(b, 0.01, ComparisonType.Absolute);
        ///     </code>
        ///     </example>
        ///     </para>
        ///     <para>
        ///     Note that it is advised against specifying zero difference, due to the nature
        ///     of floating point operations and using System.Double internally.
        ///     </para>
        /// </summary>
        /// <param name="other">The other quantity to compare to.</param>
        /// <param name="tolerance">The absolute or relative tolerance value. Must be greater than or equal to 0.</param>
        /// <param name="comparisonType">The comparison type: either relative or absolute.</param>
        /// <returns>True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.</returns>
        public bool Equals(Humidity other, double tolerance, ComparisonType comparisonType)
        {
            if (tolerance < 0)
            {
                throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0.");
            }

            double thisValue             = (double)this.Value;
            double otherValueInThisUnits = other.As(this.Unit);

            return(UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType));
        }
コード例 #3
0
ファイル: Humidity.g.cs プロジェクト: ilchdeveloper/UnitsNet
 public bool Equals(Humidity other)
 {
     return(_value.Equals(other.AsBaseNumericType(this.Unit)));
 }
コード例 #4
0
ファイル: Humidity.g.cs プロジェクト: ilchdeveloper/UnitsNet
 // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods
 internal int CompareTo(Humidity other)
 {
     return(_value.CompareTo(other.AsBaseNumericType(this.Unit)));
 }
コード例 #5
0
ファイル: Humidity.g.cs プロジェクト: ilchdeveloper/UnitsNet
        /// <summary>
        ///     Try to parse a string with one or two quantities of the format "&lt;quantity&gt; &lt;unit&gt;".
        /// </summary>
        /// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
        /// <param name="result">Resulting unit quantity if successful.</param>
        /// <returns>True if successful, otherwise false.</returns>
        /// <example>
        ///     Length.Parse("5.5 m", new CultureInfo("en-US"));
        /// </example>
        /// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
        public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Humidity result)
        {
            IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);

            return(QuantityParser.Default.TryParse <Humidity, HumidityUnit>(
                       str,
                       provider,
                       From,
                       out result));
        }
コード例 #6
0
ファイル: Humidity.g.cs プロジェクト: ilchdeveloper/UnitsNet
 /// <summary>
 ///     Try to parse a string with one or two quantities of the format "&lt;quantity&gt; &lt;unit&gt;".
 /// </summary>
 /// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
 /// <param name="result">Resulting unit quantity if successful.</param>
 /// <example>
 ///     Length.Parse("5.5 m", new CultureInfo("en-US"));
 /// </example>
 public static bool TryParse([CanBeNull] string str, out Humidity result)
 {
     return(TryParse(str, null, out result));
 }
コード例 #7
0
ファイル: Humidity.g.cs プロジェクト: ilchdeveloper/UnitsNet
 public bool Equals(Humidity other)
 {
     return(_value.Equals(other.GetValueAs(this.Unit)));
 }
コード例 #8
0
ファイル: Humidity.g.cs プロジェクト: ilchdeveloper/UnitsNet
 public int CompareTo(Humidity other)
 {
     return(_value.CompareTo(other.GetValueAs(this.Unit)));
 }
コード例 #9
0
ファイル: Quantity.g.cs プロジェクト: ilchdeveloper/UnitsNet
        /// <summary>
        ///     Try to dynamically construct a quantity.
        /// </summary>
        /// <param name="value">Numeric value.</param>
        /// <param name="unit">Unit enum value.</param>
        /// <param name="quantity">The resulting quantity if successful, otherwise <c>default</c>.</param>
        /// <returns><c>True</c> if successful with <paramref name="quantity"/> assigned the value, otherwise <c>false</c>.</returns>
        internal static bool TryFrom(double value, Enum unit, out IQuantity quantity)
        {
            switch (unit)
            {
            case AccelerationUnit accelerationUnit:
                quantity = Acceleration.From(value, accelerationUnit);
                return(true);

            case AmountOfSubstanceUnit amountOfSubstanceUnit:
                quantity = AmountOfSubstance.From(value, amountOfSubstanceUnit);
                return(true);

            case AmplitudeRatioUnit amplitudeRatioUnit:
                quantity = AmplitudeRatio.From(value, amplitudeRatioUnit);
                return(true);

            case AngleUnit angleUnit:
                quantity = Angle.From(value, angleUnit);
                return(true);

            case ApparentEnergyUnit apparentEnergyUnit:
                quantity = ApparentEnergy.From(value, apparentEnergyUnit);
                return(true);

            case ApparentPowerUnit apparentPowerUnit:
                quantity = ApparentPower.From(value, apparentPowerUnit);
                return(true);

            case AreaUnit areaUnit:
                quantity = Area.From(value, areaUnit);
                return(true);

            case AreaDensityUnit areaDensityUnit:
                quantity = AreaDensity.From(value, areaDensityUnit);
                return(true);

            case AreaMomentOfInertiaUnit areaMomentOfInertiaUnit:
                quantity = AreaMomentOfInertia.From(value, areaMomentOfInertiaUnit);
                return(true);

            case BitRateUnit bitRateUnit:
                quantity = BitRate.From(value, bitRateUnit);
                return(true);

            case BrakeSpecificFuelConsumptionUnit brakeSpecificFuelConsumptionUnit:
                quantity = BrakeSpecificFuelConsumption.From(value, brakeSpecificFuelConsumptionUnit);
                return(true);

            case CapacitanceUnit capacitanceUnit:
                quantity = Capacitance.From(value, capacitanceUnit);
                return(true);

            case CoefficientOfThermalExpansionUnit coefficientOfThermalExpansionUnit:
                quantity = CoefficientOfThermalExpansion.From(value, coefficientOfThermalExpansionUnit);
                return(true);

            case DensityUnit densityUnit:
                quantity = Density.From(value, densityUnit);
                return(true);

            case DurationUnit durationUnit:
                quantity = Duration.From(value, durationUnit);
                return(true);

            case DynamicViscosityUnit dynamicViscosityUnit:
                quantity = DynamicViscosity.From(value, dynamicViscosityUnit);
                return(true);

            case ElectricAdmittanceUnit electricAdmittanceUnit:
                quantity = ElectricAdmittance.From(value, electricAdmittanceUnit);
                return(true);

            case ElectricChargeUnit electricChargeUnit:
                quantity = ElectricCharge.From(value, electricChargeUnit);
                return(true);

            case ElectricChargeDensityUnit electricChargeDensityUnit:
                quantity = ElectricChargeDensity.From(value, electricChargeDensityUnit);
                return(true);

            case ElectricConductanceUnit electricConductanceUnit:
                quantity = ElectricConductance.From(value, electricConductanceUnit);
                return(true);

            case ElectricConductivityUnit electricConductivityUnit:
                quantity = ElectricConductivity.From(value, electricConductivityUnit);
                return(true);

            case ElectricCurrentUnit electricCurrentUnit:
                quantity = ElectricCurrent.From(value, electricCurrentUnit);
                return(true);

            case ElectricCurrentDensityUnit electricCurrentDensityUnit:
                quantity = ElectricCurrentDensity.From(value, electricCurrentDensityUnit);
                return(true);

            case ElectricCurrentGradientUnit electricCurrentGradientUnit:
                quantity = ElectricCurrentGradient.From(value, electricCurrentGradientUnit);
                return(true);

            case ElectricFieldUnit electricFieldUnit:
                quantity = ElectricField.From(value, electricFieldUnit);
                return(true);

            case ElectricInductanceUnit electricInductanceUnit:
                quantity = ElectricInductance.From(value, electricInductanceUnit);
                return(true);

            case ElectricPotentialUnit electricPotentialUnit:
                quantity = ElectricPotential.From(value, electricPotentialUnit);
                return(true);

            case ElectricPotentialAcUnit electricPotentialAcUnit:
                quantity = ElectricPotentialAc.From(value, electricPotentialAcUnit);
                return(true);

            case ElectricPotentialChangeRateUnit electricPotentialChangeRateUnit:
                quantity = ElectricPotentialChangeRate.From(value, electricPotentialChangeRateUnit);
                return(true);

            case ElectricPotentialDcUnit electricPotentialDcUnit:
                quantity = ElectricPotentialDc.From(value, electricPotentialDcUnit);
                return(true);

            case ElectricResistanceUnit electricResistanceUnit:
                quantity = ElectricResistance.From(value, electricResistanceUnit);
                return(true);

            case ElectricResistivityUnit electricResistivityUnit:
                quantity = ElectricResistivity.From(value, electricResistivityUnit);
                return(true);

            case ElectricSurfaceChargeDensityUnit electricSurfaceChargeDensityUnit:
                quantity = ElectricSurfaceChargeDensity.From(value, electricSurfaceChargeDensityUnit);
                return(true);

            case EnergyUnit energyUnit:
                quantity = Energy.From(value, energyUnit);
                return(true);

            case EntropyUnit entropyUnit:
                quantity = Entropy.From(value, entropyUnit);
                return(true);

            case ForceUnit forceUnit:
                quantity = Force.From(value, forceUnit);
                return(true);

            case ForceChangeRateUnit forceChangeRateUnit:
                quantity = ForceChangeRate.From(value, forceChangeRateUnit);
                return(true);

            case ForcePerLengthUnit forcePerLengthUnit:
                quantity = ForcePerLength.From(value, forcePerLengthUnit);
                return(true);

            case FrequencyUnit frequencyUnit:
                quantity = Frequency.From(value, frequencyUnit);
                return(true);

            case FuelEfficiencyUnit fuelEfficiencyUnit:
                quantity = FuelEfficiency.From(value, fuelEfficiencyUnit);
                return(true);

            case HeatFluxUnit heatFluxUnit:
                quantity = HeatFlux.From(value, heatFluxUnit);
                return(true);

            case HeatTransferCoefficientUnit heatTransferCoefficientUnit:
                quantity = HeatTransferCoefficient.From(value, heatTransferCoefficientUnit);
                return(true);

            case HumidityUnit humidityUnit:
                quantity = Humidity.From(value, humidityUnit);
                return(true);

            case IlluminanceUnit illuminanceUnit:
                quantity = Illuminance.From(value, illuminanceUnit);
                return(true);

            case InformationUnit informationUnit:
                quantity = Information.From(value, informationUnit);
                return(true);

            case IrradianceUnit irradianceUnit:
                quantity = Irradiance.From(value, irradianceUnit);
                return(true);

            case IrradiationUnit irradiationUnit:
                quantity = Irradiation.From(value, irradiationUnit);
                return(true);

            case KinematicViscosityUnit kinematicViscosityUnit:
                quantity = KinematicViscosity.From(value, kinematicViscosityUnit);
                return(true);

            case LapseRateUnit lapseRateUnit:
                quantity = LapseRate.From(value, lapseRateUnit);
                return(true);

            case LengthUnit lengthUnit:
                quantity = Length.From(value, lengthUnit);
                return(true);

            case LevelUnit levelUnit:
                quantity = Level.From(value, levelUnit);
                return(true);

            case LinearDensityUnit linearDensityUnit:
                quantity = LinearDensity.From(value, linearDensityUnit);
                return(true);

            case LinearPowerDensityUnit linearPowerDensityUnit:
                quantity = LinearPowerDensity.From(value, linearPowerDensityUnit);
                return(true);

            case LuminosityUnit luminosityUnit:
                quantity = Luminosity.From(value, luminosityUnit);
                return(true);

            case LuminousFluxUnit luminousFluxUnit:
                quantity = LuminousFlux.From(value, luminousFluxUnit);
                return(true);

            case LuminousIntensityUnit luminousIntensityUnit:
                quantity = LuminousIntensity.From(value, luminousIntensityUnit);
                return(true);

            case MagneticFieldUnit magneticFieldUnit:
                quantity = MagneticField.From(value, magneticFieldUnit);
                return(true);

            case MagneticFluxUnit magneticFluxUnit:
                quantity = MagneticFlux.From(value, magneticFluxUnit);
                return(true);

            case MagnetizationUnit magnetizationUnit:
                quantity = Magnetization.From(value, magnetizationUnit);
                return(true);

            case MassUnit massUnit:
                quantity = Mass.From(value, massUnit);
                return(true);

            case MassConcentrationUnit massConcentrationUnit:
                quantity = MassConcentration.From(value, massConcentrationUnit);
                return(true);

            case MassFlowUnit massFlowUnit:
                quantity = MassFlow.From(value, massFlowUnit);
                return(true);

            case MassFluxUnit massFluxUnit:
                quantity = MassFlux.From(value, massFluxUnit);
                return(true);

            case MassFractionUnit massFractionUnit:
                quantity = MassFraction.From(value, massFractionUnit);
                return(true);

            case MassMomentOfInertiaUnit massMomentOfInertiaUnit:
                quantity = MassMomentOfInertia.From(value, massMomentOfInertiaUnit);
                return(true);

            case MolarEnergyUnit molarEnergyUnit:
                quantity = MolarEnergy.From(value, molarEnergyUnit);
                return(true);

            case MolarEntropyUnit molarEntropyUnit:
                quantity = MolarEntropy.From(value, molarEntropyUnit);
                return(true);

            case MolarityUnit molarityUnit:
                quantity = Molarity.From(value, molarityUnit);
                return(true);

            case MolarMassUnit molarMassUnit:
                quantity = MolarMass.From(value, molarMassUnit);
                return(true);

            case PermeabilityUnit permeabilityUnit:
                quantity = Permeability.From(value, permeabilityUnit);
                return(true);

            case PermittivityUnit permittivityUnit:
                quantity = Permittivity.From(value, permittivityUnit);
                return(true);

            case PowerUnit powerUnit:
                quantity = Power.From(value, powerUnit);
                return(true);

            case PowerDensityUnit powerDensityUnit:
                quantity = PowerDensity.From(value, powerDensityUnit);
                return(true);

            case PowerRatioUnit powerRatioUnit:
                quantity = PowerRatio.From(value, powerRatioUnit);
                return(true);

            case PressureUnit pressureUnit:
                quantity = Pressure.From(value, pressureUnit);
                return(true);

            case PressureChangeRateUnit pressureChangeRateUnit:
                quantity = PressureChangeRate.From(value, pressureChangeRateUnit);
                return(true);

            case RatioUnit ratioUnit:
                quantity = Ratio.From(value, ratioUnit);
                return(true);

            case RatioChangeRateUnit ratioChangeRateUnit:
                quantity = RatioChangeRate.From(value, ratioChangeRateUnit);
                return(true);

            case ReactiveEnergyUnit reactiveEnergyUnit:
                quantity = ReactiveEnergy.From(value, reactiveEnergyUnit);
                return(true);

            case ReactivePowerUnit reactivePowerUnit:
                quantity = ReactivePower.From(value, reactivePowerUnit);
                return(true);

            case RotationalAccelerationUnit rotationalAccelerationUnit:
                quantity = RotationalAcceleration.From(value, rotationalAccelerationUnit);
                return(true);

            case RotationalSpeedUnit rotationalSpeedUnit:
                quantity = RotationalSpeed.From(value, rotationalSpeedUnit);
                return(true);

            case RotationalStiffnessUnit rotationalStiffnessUnit:
                quantity = RotationalStiffness.From(value, rotationalStiffnessUnit);
                return(true);

            case RotationalStiffnessPerLengthUnit rotationalStiffnessPerLengthUnit:
                quantity = RotationalStiffnessPerLength.From(value, rotationalStiffnessPerLengthUnit);
                return(true);

            case SolidAngleUnit solidAngleUnit:
                quantity = SolidAngle.From(value, solidAngleUnit);
                return(true);

            case SpecificEnergyUnit specificEnergyUnit:
                quantity = SpecificEnergy.From(value, specificEnergyUnit);
                return(true);

            case SpecificEntropyUnit specificEntropyUnit:
                quantity = SpecificEntropy.From(value, specificEntropyUnit);
                return(true);

            case SpecificVolumeUnit specificVolumeUnit:
                quantity = SpecificVolume.From(value, specificVolumeUnit);
                return(true);

            case SpecificWeightUnit specificWeightUnit:
                quantity = SpecificWeight.From(value, specificWeightUnit);
                return(true);

            case SpeedUnit speedUnit:
                quantity = Speed.From(value, speedUnit);
                return(true);

            case TemperatureUnit temperatureUnit:
                quantity = Temperature.From(value, temperatureUnit);
                return(true);

            case TemperatureChangeRateUnit temperatureChangeRateUnit:
                quantity = TemperatureChangeRate.From(value, temperatureChangeRateUnit);
                return(true);

            case TemperatureDeltaUnit temperatureDeltaUnit:
                quantity = TemperatureDelta.From(value, temperatureDeltaUnit);
                return(true);

            case ThermalConductivityUnit thermalConductivityUnit:
                quantity = ThermalConductivity.From(value, thermalConductivityUnit);
                return(true);

            case ThermalResistanceUnit thermalResistanceUnit:
                quantity = ThermalResistance.From(value, thermalResistanceUnit);
                return(true);

            case TorqueUnit torqueUnit:
                quantity = Torque.From(value, torqueUnit);
                return(true);

            case TorquePerLengthUnit torquePerLengthUnit:
                quantity = TorquePerLength.From(value, torquePerLengthUnit);
                return(true);

            case VitaminAUnit vitaminAUnit:
                quantity = VitaminA.From(value, vitaminAUnit);
                return(true);

            case VolumeUnit volumeUnit:
                quantity = Volume.From(value, volumeUnit);
                return(true);

            case VolumeConcentrationUnit volumeConcentrationUnit:
                quantity = VolumeConcentration.From(value, volumeConcentrationUnit);
                return(true);

            case VolumeFlowUnit volumeFlowUnit:
                quantity = VolumeFlow.From(value, volumeFlowUnit);
                return(true);

            case VolumePerLengthUnit volumePerLengthUnit:
                quantity = VolumePerLength.From(value, volumePerLengthUnit);
                return(true);

            default:
            {
                quantity = default(IQuantity);
                return(false);
            }
            }
        }