Skip to content

Commit 66aafab

Browse files
committed
Make UnitConverter.Convert/TryConvert public
Except for WRC.
1 parent f4bdc12 commit 66aafab

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

UnitsNet/UnitConverter.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,32 @@ public static class UnitConverter
6060
/// <param name="fromUnitValue">From unit enum value.</param>
6161
/// <param name="toUnitValue">To unit enum value, must be compatible with <paramref name="fromUnitValue" />.</param>
6262
/// <returns>The converted value in the new unit representation.</returns>
63-
internal static double Convert(FromValue fromValue, Enum fromUnitValue, Enum toUnitValue)
63+
#if WINDOWS_UWP
64+
internal
65+
#else
66+
public
67+
#endif
68+
static double Convert(FromValue fromValue, Enum fromUnitValue, Enum toUnitValue)
6469
{
6570
return Quantity
6671
.From(fromValue, fromUnitValue)
6772
.As(toUnitValue);
6873
}
6974

70-
internal static bool TryConvert(FromValue fromValue, Enum fromUnitValue, Enum toUnitValue, out double convertedValue)
75+
/// <summary>
76+
/// Try to convert between any two quantity units given a numeric value and two unit enum values.
77+
/// </summary>
78+
/// <param name="fromValue">Numeric value.</param>
79+
/// <param name="fromUnitValue">From unit enum value.</param>
80+
/// <param name="toUnitValue">To unit enum value, must be compatible with <paramref name="fromUnitValue" />.</param>
81+
/// <param name="convertedValue">The converted value, if successful. Otherwise default.</param>
82+
/// <returns>True if successful.</returns>
83+
#if WINDOWS_UWP
84+
internal
85+
#else
86+
public
87+
#endif
88+
static bool TryConvert(FromValue fromValue, Enum fromUnitValue, Enum toUnitValue, out double convertedValue)
7189
{
7290
convertedValue = 0;
7391
if (!Quantity.TryFrom(fromValue, fromUnitValue, out IQuantity from)) return false;

0 commit comments

Comments
 (0)