diff --git a/UnitsNet/CustomCode/UnitSystem.cs b/UnitsNet/CustomCode/UnitSystem.cs
index 96480fe653..ea3f4bac28 100644
--- a/UnitsNet/CustomCode/UnitSystem.cs
+++ b/UnitsNet/CustomCode/UnitSystem.cs
@@ -31,6 +31,14 @@
// ReSharper disable once CheckNamespace
namespace UnitsNet
{
+ ///
+ /// Main facade for working with units dynamically and configuring default behavior for quantities' ToString():
+ /// - Instance per culture via , for caching number formatting and unit abbreviation localization
+ /// - Use for local system's current culture
+ /// - Override to affect number formatting and localization of all quantities' ToString() when culture is not specified
+ /// - unit abbreviations with dynamic types
+ /// - Dynamically add abbreviations to unit enums with
+ ///
[PublicAPI]
public sealed partial class UnitSystem
{
@@ -38,11 +46,11 @@ public sealed partial class UnitSystem
///
/// Fallback culture used by and
- ///
+ ///
/// if no abbreviations are found with current .
///
///
- /// User wants to call or with Russian
+ /// User wants to call or with Russian
/// culture, but no translation is defined, so we return the US English definition as a last resort. If it's not
/// defined there either, an exception is thrown.
///
@@ -147,8 +155,15 @@ public UnitSystem() : this(DefaultCulture)
#endif
static IFormatProvider DefaultCulture { get; set; } = CultureInfo.CurrentUICulture;
- public bool IsFallbackCulture => Culture.Equals(FallbackCulture);
+ ///
+ /// Whether this instance is for the .
+ ///
+ private bool IsFallbackCulture => Culture.Equals(FallbackCulture);
+ ///
+ /// Clear the cached singleton instances.
+ /// Calling or afterwards will create a new instance.
+ ///
[PublicAPI]
public static void ClearCache()
{
@@ -185,6 +200,11 @@ public static UnitSystem GetCached([CanBeNull] string cultureName)
}
// 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
+ ///
+ /// Gets or creates the singleton instance configured with localized unit abbreviations and number formatting for the given culture.
+ ///
+ /// The culture.
+ /// The instance.
#if WINDOWS_UWP
internal
#else
@@ -205,19 +225,13 @@ static UnitSystem GetCached([CanBeNull] IFormatProvider cultureInfo)
}
}
- [PublicAPI]
- // 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
-#if WINDOWS_UWP
- internal
-#else
- public
-#endif
- static TUnitType Parse(string unitAbbreviation, IFormatProvider culture)
- where TUnitType : /*Enum constraint hack*/ struct, IComparable, IFormattable
- {
- return GetCached(culture).Parse(unitAbbreviation);
- }
-
+ ///
+ /// Parses a unit abbreviation for a given unit enumeration type.
+ /// Example: Parse<LengthUnit>("km") => LengthUnit.Kilometer
+ ///
+ ///
+ ///
+ ///
[PublicAPI]
// 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
#if WINDOWS_UWP
@@ -246,12 +260,10 @@ TUnitType Parse(string unitAbbreviation)
[PublicAPI]
public object Parse(string unitAbbreviation, Type unitType)
{
- AbbreviationMap abbrevToUnitValue;
- if (!_unitTypeToAbbrevToUnitValue.TryGetValue(unitType, out abbrevToUnitValue))
+ if (!_unitTypeToAbbrevToUnitValue.TryGetValue(unitType, out var abbrevToUnitValue))
throw new UnitNotFoundException($"No abbreviations defined for unit type [{unitType}] for culture [{Culture}].");
- List unitIntValues;
- List