Skip to content

Commit

Permalink
Revert "🔥Remove static Default getters, obsoleted by UnitsNetSetup (#…
Browse files Browse the repository at this point in the history
…1475)"

This reverts commit a3c32b6.

- Add back default getters
- Remove obsolete message, rewrite xmldoc a bit
  • Loading branch information
angularsen committed Dec 29, 2024
1 parent 3f1456d commit b0180c6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
8 changes: 8 additions & 0 deletions UnitsNet/CustomCode/QuantityParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ public class QuantityParser
private readonly UnitAbbreviationsCache _unitAbbreviationsCache;
private readonly UnitParser _unitParser;

/// <summary>
/// The default singleton instance for parsing quantities.
/// </summary>
/// <remarks>
/// Convenience shortcut for <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.QuantityParser"/>.
/// </remarks>
public static QuantityParser Default => UnitsNetSetup.Default.QuantityParser;

/// <summary>
/// Creates an instance of <see cref="QuantityParser"/>, optionally specifying an <see cref="UnitAbbreviationsCache"/>
/// with unit abbreviations to use when parsing.
Expand Down
9 changes: 9 additions & 0 deletions UnitsNet/CustomCode/UnitAbbreviationsCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ public sealed class UnitAbbreviationsCache
/// </example>
internal static readonly CultureInfo FallbackCulture = CultureInfo.InvariantCulture;

/// <summary>
/// The default singleton instance with the default configured unit abbreviations, used for ToString() and parsing of quantities and units.
/// </summary>
/// <remarks>
/// Convenience shortcut for <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitAbbreviations"/>.<br />
/// You can add custom unit abbreviations at runtime, and this will affect all usages globally in the application.
/// </remarks>
public static UnitAbbreviationsCache Default => UnitsNetSetup.Default.UnitAbbreviations;

private QuantityInfoLookup QuantityInfoLookup { get; }

/// <summary>
Expand Down
12 changes: 10 additions & 2 deletions UnitsNet/CustomCode/UnitParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ namespace UnitsNet
{
/// <summary>
/// Parses units given a unit abbreviations cache.
/// A static instance <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitParser"/> is used internally
/// to parse quantities and units using the default abbreviations cache for all units and abbreviations defined in the library.
/// The static instance <see cref="Default"/> is used internally to parse quantities and units using the
/// default abbreviations cache for all units and abbreviations defined in the library.
/// </summary>
public sealed class UnitParser
{
private readonly UnitAbbreviationsCache _unitAbbreviationsCache;

/// <summary>
/// The default singleton instance for parsing units from the default configured unit abbreviations.
/// </summary>
/// <remarks>
/// Convenience shortcut for <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitParser"/>.
/// </remarks>
public static UnitParser Default => UnitsNetSetup.Default.UnitParser;

/// <summary>
/// Create a parser using the given unit abbreviations cache.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions UnitsNet/UnitConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public delegate TQuantity ConversionFunction<TQuantity>(TQuantity inputValue)
/// </summary>
public sealed class UnitConverter
{
/// <summary>
/// The default singleton instance for converting values from one unit to another.<br />
/// Modify this to add/remove conversion functions at runtime, such as adding your own third-party units and quantities to convert between.
/// </summary>
/// <remarks>
/// Convenience shortcut for <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitConverter"/>.
/// </remarks>
public static UnitConverter Default => UnitsNetSetup.Default.UnitConverter;

/// <summary>
/// Creates a new <see cref="UnitConverter"/> instance.
/// </summary>
Expand Down

0 comments on commit b0180c6

Please sign in to comment.