Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "🔥Remove static Default getters, obsoleted by UnitsNetSetup" #1480

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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