@@ -46,7 +46,7 @@ public static bool TryGetUnitInfo(Enum unitEnum, [NotNullWhen(true)] out UnitInf
4646 /// <param name="unit">Unit enum value.</param>
4747 /// <returns>An <see cref="IQuantity"/> object.</returns>
4848 /// <exception cref="UnitNotFoundException">Unit value is not a known unit enum type.</exception>
49- public static IQuantity From ( QuantityValue value , Enum unit )
49+ public static IQuantity From ( double value , Enum unit )
5050 {
5151 return TryFrom ( value , unit , out IQuantity ? quantity )
5252 ? quantity
@@ -61,7 +61,7 @@ public static IQuantity From(QuantityValue value, Enum unit)
6161 /// <param name="unitName">The invariant unit enum name, such as "Meter". Does not support localization.</param>
6262 /// <returns>An <see cref="IQuantity"/> object.</returns>
6363 /// <exception cref="ArgumentException">Unit value is not a known unit enum type.</exception>
64- public static IQuantity From ( QuantityValue value , string quantityName , string unitName )
64+ public static IQuantity From ( double value , string quantityName , string unitName )
6565 {
6666 // Get enum value for this unit, f.ex. LengthUnit.Meter for unit name "Meter".
6767 return UnitConverter . TryParseUnit ( quantityName , unitName , out Enum ? unitValue ) &&
@@ -78,14 +78,14 @@ public static IQuantity From(QuantityValue value, string quantityName, string un
7878 /// Unit abbreviation matching is case-insensitive.<br/>
7979 /// <br/>
8080 /// This will fail if more than one unit across all quantities share the same unit abbreviation.<br/>
81- /// Prefer <see cref="From(UnitsNet.QuantityValue ,System.Enum)"/> or <see cref="From(UnitsNet.QuantityValue ,string,string)"/> instead.
81+ /// Prefer <see cref="From(double ,System.Enum)"/> or <see cref="From(double ,string,string)"/> instead.
8282 /// </remarks>
8383 /// <param name="value">Numeric value.</param>
8484 /// <param name="unitAbbreviation">Unit abbreviation, such as "kg" for <see cref="MassUnit.Kilogram"/>.</param>
8585 /// <returns>An <see cref="IQuantity"/> object.</returns>
8686 /// <exception cref="UnitNotFoundException">Unit abbreviation is not known.</exception>
8787 /// <exception cref="AmbiguousUnitParseException">Multiple units found matching the given unit abbreviation.</exception>
88- public static IQuantity FromUnitAbbreviation ( QuantityValue value , string unitAbbreviation ) => FromUnitAbbreviation ( null , value , unitAbbreviation ) ;
88+ public static IQuantity FromUnitAbbreviation ( double value , string unitAbbreviation ) => FromUnitAbbreviation ( null , value , unitAbbreviation ) ;
8989
9090 /// <summary>
9191 /// Dynamically construct a quantity from a numeric value and a unit abbreviation.
@@ -95,15 +95,15 @@ public static IQuantity From(QuantityValue value, string quantityName, string un
9595 /// Unit abbreviation matching is case-insensitive.<br/>
9696 /// <br/>
9797 /// This will fail if more than one unit across all quantities share the same unit abbreviation.<br/>
98- /// Prefer <see cref="From(UnitsNet.QuantityValue ,System.Enum)"/> or <see cref="From(UnitsNet.QuantityValue ,string,string)"/> instead.
98+ /// Prefer <see cref="From(double ,System.Enum)"/> or <see cref="From(double ,string,string)"/> instead.
9999 /// </remarks>
100100 /// <param name="formatProvider">The format provider to use for lookup. Defaults to <see cref="CultureInfo.CurrentCulture" /> if null.</param>
101101 /// <param name="value">Numeric value.</param>
102102 /// <param name="unitAbbreviation">Unit abbreviation, such as "kg" for <see cref="MassUnit.Kilogram"/>.</param>
103103 /// <returns>An <see cref="IQuantity"/> object.</returns>
104104 /// <exception cref="UnitNotFoundException">Unit abbreviation is not known.</exception>
105105 /// <exception cref="AmbiguousUnitParseException">Multiple units found matching the given unit abbreviation.</exception>
106- public static IQuantity FromUnitAbbreviation ( IFormatProvider ? formatProvider , QuantityValue value , string unitAbbreviation )
106+ public static IQuantity FromUnitAbbreviation ( IFormatProvider ? formatProvider , double value , string unitAbbreviation )
107107 {
108108 // TODO Optimize this with UnitValueAbbreviationLookup via UnitAbbreviationsCache.TryGetUnitValueAbbreviationLookup.
109109 List < Enum > units = GetUnitsForAbbreviation ( formatProvider , unitAbbreviation ) ;
@@ -121,16 +121,6 @@ public static IQuantity FromUnitAbbreviation(IFormatProvider? formatProvider, Qu
121121 return From ( value , unit ) ;
122122 }
123123
124- /// <inheritdoc cref="TryFrom(QuantityValue,System.Enum,out UnitsNet.IQuantity)"/>
125- public static bool TryFrom ( double value , Enum unit , [ NotNullWhen ( true ) ] out IQuantity ? quantity )
126- {
127- quantity = default ;
128-
129- // Implicit cast to QuantityValue would prevent TryFrom from being called,
130- // so we need to explicitly check this here for double arguments.
131- return TryFrom ( ( QuantityValue ) value , unit , out quantity ) ;
132- }
133-
134124 /// <summary>
135125 /// Try to dynamically construct a quantity from a value, the quantity name and the unit name.
136126 /// </summary>
@@ -155,14 +145,14 @@ public static bool TryFrom(double value, string quantityName, string unitName, [
155145 /// Unit abbreviation matching is case-insensitive.<br/>
156146 /// <br/>
157147 /// This will fail if more than one unit across all quantities share the same unit abbreviation.<br/>
158- /// Prefer <see cref="From(UnitsNet.QuantityValue ,System.Enum)"/> or <see cref="From(UnitsNet.QuantityValue ,string,string)"/> instead.
148+ /// Prefer <see cref="From(double ,System.Enum)"/> or <see cref="From(double ,string,string)"/> instead.
159149 /// </remarks>
160150 /// <param name="value">Numeric value.</param>
161151 /// <param name="unitAbbreviation">Unit abbreviation, such as "kg" for <see cref="MassUnit.Kilogram"/>.</param>
162152 /// <param name="quantity">The quantity if successful, otherwise null.</param>
163153 /// <returns>True if successful.</returns>
164154 /// <exception cref="ArgumentException">Unit value is not a known unit enum type.</exception>
165- public static bool TryFromUnitAbbreviation ( QuantityValue value , string unitAbbreviation , [ NotNullWhen ( true ) ] out IQuantity ? quantity ) =>
155+ public static bool TryFromUnitAbbreviation ( double value , string unitAbbreviation , [ NotNullWhen ( true ) ] out IQuantity ? quantity ) =>
166156 TryFromUnitAbbreviation ( null , value , unitAbbreviation , out quantity ) ;
167157
168158 /// <summary>
@@ -173,15 +163,15 @@ public static bool TryFromUnitAbbreviation(QuantityValue value, string unitAbbre
173163 /// Unit abbreviation matching is case-insensitive.<br/>
174164 /// <br/>
175165 /// This will fail if more than one unit across all quantities share the same unit abbreviation.<br/>
176- /// Prefer <see cref="From(UnitsNet.QuantityValue ,System.Enum)"/> or <see cref="From(UnitsNet.QuantityValue ,string,string)"/> instead.
166+ /// Prefer <see cref="From(double ,System.Enum)"/> or <see cref="From(double ,string,string)"/> instead.
177167 /// </remarks>
178168 /// <param name="formatProvider">The format provider to use for lookup. Defaults to <see cref="CultureInfo.CurrentCulture" /> if null.</param>
179169 /// <param name="value">Numeric value.</param>
180170 /// <param name="unitAbbreviation">Unit abbreviation, such as "kg" for <see cref="MassUnit.Kilogram"/>.</param>
181171 /// <param name="quantity">The quantity if successful, otherwise null.</param>
182172 /// <returns>True if successful.</returns>
183173 /// <exception cref="ArgumentException">Unit value is not a known unit enum type.</exception>
184- public static bool TryFromUnitAbbreviation ( IFormatProvider ? formatProvider , QuantityValue value , string unitAbbreviation , [ NotNullWhen ( true ) ] out IQuantity ? quantity )
174+ public static bool TryFromUnitAbbreviation ( IFormatProvider ? formatProvider , double value , string unitAbbreviation , [ NotNullWhen ( true ) ] out IQuantity ? quantity )
185175 {
186176 // TODO Optimize this with UnitValueAbbreviationLookup via UnitAbbreviationsCache.TryGetUnitValueAbbreviationLookup.
187177 List < Enum > units = GetUnitsForAbbreviation ( formatProvider , unitAbbreviation ) ;
0 commit comments