Skip to content

Commit 804cf7e

Browse files
authored
Revert "🔥Remove static Default getters, obsoleted by UnitsNetSetup" (#1480)
Reverts #1475 This reverts commit a3c32b6. - Add back default getters - Remove obsolete message, rewrite xmldoc a bit
1 parent 3f1456d commit 804cf7e

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

‎UnitsNet/CustomCode/QuantityParser.cs

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ public class QuantityParser
3434
private readonly UnitAbbreviationsCache _unitAbbreviationsCache;
3535
private readonly UnitParser _unitParser;
3636

37+
/// <summary>
38+
/// The default singleton instance for parsing quantities.
39+
/// </summary>
40+
/// <remarks>
41+
/// Convenience shortcut for <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.QuantityParser"/>.
42+
/// </remarks>
43+
public static QuantityParser Default => UnitsNetSetup.Default.QuantityParser;
44+
3745
/// <summary>
3846
/// Creates an instance of <see cref="QuantityParser"/>, optionally specifying an <see cref="UnitAbbreviationsCache"/>
3947
/// with unit abbreviations to use when parsing.

‎UnitsNet/CustomCode/UnitAbbreviationsCache.cs

+9
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ public sealed class UnitAbbreviationsCache
3131
/// </example>
3232
internal static readonly CultureInfo FallbackCulture = CultureInfo.InvariantCulture;
3333

34+
/// <summary>
35+
/// The default singleton instance with the default configured unit abbreviations, used for ToString() and parsing of quantities and units.
36+
/// </summary>
37+
/// <remarks>
38+
/// Convenience shortcut for <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitAbbreviations"/>.<br />
39+
/// You can add custom unit abbreviations at runtime, and this will affect all usages globally in the application.
40+
/// </remarks>
41+
public static UnitAbbreviationsCache Default => UnitsNetSetup.Default.UnitAbbreviations;
42+
3443
private QuantityInfoLookup QuantityInfoLookup { get; }
3544

3645
/// <summary>

‎UnitsNet/CustomCode/UnitParser.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@ namespace UnitsNet
1313
{
1414
/// <summary>
1515
/// Parses units given a unit abbreviations cache.
16-
/// A static instance <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitParser"/> is used internally
17-
/// to parse quantities and units using the default abbreviations cache for all units and abbreviations defined in the library.
16+
/// The static instance <see cref="Default"/> is used internally to parse quantities and units using the
17+
/// default abbreviations cache for all units and abbreviations defined in the library.
1818
/// </summary>
1919
public sealed class UnitParser
2020
{
2121
private readonly UnitAbbreviationsCache _unitAbbreviationsCache;
2222

23+
/// <summary>
24+
/// The default singleton instance for parsing units from the default configured unit abbreviations.
25+
/// </summary>
26+
/// <remarks>
27+
/// Convenience shortcut for <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitParser"/>.
28+
/// </remarks>
29+
public static UnitParser Default => UnitsNetSetup.Default.UnitParser;
30+
2331
/// <summary>
2432
/// Create a parser using the given unit abbreviations cache.
2533
/// </summary>

‎UnitsNet/UnitConverter.cs

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public delegate TQuantity ConversionFunction<TQuantity>(TQuantity inputValue)
3434
/// </summary>
3535
public sealed class UnitConverter
3636
{
37+
/// <summary>
38+
/// The default singleton instance for converting values from one unit to another.<br />
39+
/// Modify this to add/remove conversion functions at runtime, such as adding your own third-party units and quantities to convert between.
40+
/// </summary>
41+
/// <remarks>
42+
/// Convenience shortcut for <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitConverter"/>.
43+
/// </remarks>
44+
public static UnitConverter Default => UnitsNetSetup.Default.UnitConverter;
45+
3746
/// <summary>
3847
/// Creates a new <see cref="UnitConverter"/> instance.
3948
/// </summary>

0 commit comments

Comments
 (0)