internal static bool TryParse <TUnit, TQuantity>(string text, Func <double, TUnit, TQuantity> creator, NumberStyles style, IFormatProvider provider, out TQuantity value) where TQuantity : struct, IQuantity <TUnit> where TUnit : struct, IUnit, IEquatable <TUnit> { var pos = 0; _ = WhiteSpaceReader.TryRead(text, ref pos); if (!DoubleReader.TryRead(text, ref pos, style, provider, out var d)) { value = default; return(false); } _ = WhiteSpaceReader.TryRead(text, ref pos); if (!UnitParser <TUnit> .TryParse(text, ref pos, out var unit)) { value = default; return(false); } _ = WhiteSpaceReader.TryRead(text, ref pos); if (pos != text.Length) { value = default; return(false); } value = creator(d, unit); return(true); }
internal static TQuantity Parse <TUnit, TQuantity>(string text, Func <double, TUnit, TQuantity> creator, NumberStyles style, IFormatProvider provider) where TQuantity : IQuantity <TUnit> where TUnit : struct, IUnit, IEquatable <TUnit> { var pos = 0; _ = WhiteSpaceReader.TryRead(text, ref pos); if (!DoubleReader.TryRead(text, ref pos, style, provider, out var d)) { throw new FormatException("Could not parse the scalar value from: " + text); } _ = WhiteSpaceReader.TryRead(text, ref pos); if (!UnitParser <TUnit> .TryParse(text, ref pos, out var unit)) { throw new FormatException("Could not parse the unit value from: " + text); } _ = WhiteSpaceReader.TryRead(text, ref pos); if (pos != text.Length) { throw new FormatException("Could not parse the unit value from: " + text); } return(creator(d, unit)); }
public static bool TryParse(string text, out ElectricChargeUnit result) { return(UnitParser <ElectricChargeUnit> .TryParse(text, out result)); }
public static bool TryParse(string text, out CatalyticActivityUnit result) { return(UnitParser <CatalyticActivityUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.FrequencyUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.FrequencyUnit"/></param> /// <param name="result">The parsed <see cref="FrequencyUnit"/></param> /// <returns>True if an instance of <see cref="FrequencyUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out FrequencyUnit result) { return(UnitParser <FrequencyUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.KinematicViscosityUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.KinematicViscosityUnit"/></param> /// <param name="result">The parsed <see cref="KinematicViscosityUnit"/></param> /// <returns>True if an instance of <see cref="KinematicViscosityUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out KinematicViscosityUnit result) { return(UnitParser <KinematicViscosityUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.PressureUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.PressureUnit"/></param> /// <param name="result">The parsed <see cref="PressureUnit"/></param> /// <returns>True if an instance of <see cref="PressureUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out PressureUnit result) { return(UnitParser <PressureUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.UnitlessUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.UnitlessUnit"/></param> /// <param name="result">The parsed <see cref="UnitlessUnit"/></param> /// <returns>True if an instance of <see cref="UnitlessUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out UnitlessUnit result) { return(UnitParser <UnitlessUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.JerkUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.JerkUnit"/></param> /// <param name="result">The parsed <see cref="JerkUnit"/></param> /// <returns>True if an instance of <see cref="JerkUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out JerkUnit result) { return(UnitParser <JerkUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.CurrentUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.CurrentUnit"/></param> /// <param name="result">The parsed <see cref="CurrentUnit"/></param> /// <returns>True if an instance of <see cref="CurrentUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out CurrentUnit result) { return(UnitParser <CurrentUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.TemperatureUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.TemperatureUnit"/></param> /// <param name="result">The parsed <see cref="TemperatureUnit"/></param> /// <returns>True if an instance of <see cref="TemperatureUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out TemperatureUnit result) { return(UnitParser <TemperatureUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.IlluminanceUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.IlluminanceUnit"/></param> /// <param name="result">The parsed <see cref="IlluminanceUnit"/></param> /// <returns>True if an instance of <see cref="IlluminanceUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out IlluminanceUnit result) { return(UnitParser <IlluminanceUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.SolidAngleUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.SolidAngleUnit"/></param> /// <param name="result">The parsed <see cref="SolidAngleUnit"/></param> /// <returns>True if an instance of <see cref="SolidAngleUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out SolidAngleUnit result) { return(UnitParser <SolidAngleUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.SpecificVolumeUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.SpecificVolumeUnit"/></param> /// <param name="result">The parsed <see cref="SpecificVolumeUnit"/></param> /// <returns>True if an instance of <see cref="SpecificVolumeUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out SpecificVolumeUnit result) { return(UnitParser <SpecificVolumeUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.MassFlowUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.MassFlowUnit"/></param> /// <param name="result">The parsed <see cref="MassFlowUnit"/></param> /// <returns>True if an instance of <see cref="MassFlowUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out MassFlowUnit result) { return(UnitParser <MassFlowUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.EnergyUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.EnergyUnit"/></param> /// <param name="result">The parsed <see cref="EnergyUnit"/></param> /// <returns>True if an instance of <see cref="EnergyUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out EnergyUnit result) { return(UnitParser <EnergyUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.MomentumUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.MomentumUnit"/></param> /// <param name="result">The parsed <see cref="MomentumUnit"/></param> /// <returns>True if an instance of <see cref="MomentumUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out MomentumUnit result) { return(UnitParser <MomentumUnit> .TryParse(text, out result)); }
public static bool TryParse(string text, out WavenumberUnit result) { return(UnitParser <WavenumberUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.MagneticFieldStrengthUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.MagneticFieldStrengthUnit"/></param> /// <param name="result">The parsed <see cref="MagneticFieldStrengthUnit"/></param> /// <returns>True if an instance of <see cref="MagneticFieldStrengthUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out MagneticFieldStrengthUnit result) { return(UnitParser <MagneticFieldStrengthUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.ResistanceUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.ResistanceUnit"/></param> /// <param name="result">The parsed <see cref="ResistanceUnit"/></param> /// <returns>True if an instance of <see cref="ResistanceUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out ResistanceUnit result) { return(UnitParser <ResistanceUnit> .TryParse(text, out result)); }
public static bool TryParse(string text, out ElectricalConductanceUnit result) { return(UnitParser <ElectricalConductanceUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.AccelerationUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.AccelerationUnit"/></param> /// <param name="result">The parsed <see cref="AccelerationUnit"/></param> /// <returns>True if an instance of <see cref="AccelerationUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out AccelerationUnit result) { return(UnitParser <AccelerationUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.VoltageUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.VoltageUnit"/></param> /// <param name="result">The parsed <see cref="VoltageUnit"/></param> /// <returns>True if an instance of <see cref="VoltageUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out VoltageUnit result) { return(UnitParser <VoltageUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.AmountOfSubstanceUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.AmountOfSubstanceUnit"/></param> /// <param name="result">The parsed <see cref="AmountOfSubstanceUnit"/></param> /// <returns>True if an instance of <see cref="AmountOfSubstanceUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out AmountOfSubstanceUnit result) { return(UnitParser <AmountOfSubstanceUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.AngularSpeedUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.AngularSpeedUnit"/></param> /// <param name="result">The parsed <see cref="AngularSpeedUnit"/></param> /// <returns>True if an instance of <see cref="AngularSpeedUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out AngularSpeedUnit result) { return(UnitParser <AngularSpeedUnit> .TryParse(text, out result)); }
public static bool TryParse(string text, out LuminousIntensityUnit result) { return(UnitParser <LuminousIntensityUnit> .TryParse(text, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.FlexibilityUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.FlexibilityUnit"/></param> /// <param name="result">The parsed <see cref="FlexibilityUnit"/></param> /// <returns>True if an instance of <see cref="FlexibilityUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out FlexibilityUnit result) { return(UnitParser <FlexibilityUnit> .TryParse(text, out result)); }
public static bool TryParse(string text, out DensityUnit result) { return(UnitParser <DensityUnit> .TryParse(text, out result)); }
public static bool TryParse(string text, out MolarHeatCapacityUnit result) { return(UnitParser <MolarHeatCapacityUnit> .TryParse(text, out result)); }