Skip to content

Commit

Permalink
Added default currency sign #45 #46
Browse files Browse the repository at this point in the history
  • Loading branch information
remyvd committed Sep 24, 2016
1 parent 6f906d1 commit ebba9fb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 44 deletions.
8 changes: 5 additions & 3 deletions src/NodaMoney/Currency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public struct Currency : IEquatable<Currency>
{
internal static readonly CurrencyRegistry Registry = new CurrencyRegistry();

/// <summary>
/// Initializes a new instance of the <see cref="Currency" /> struct.
/// </summary>
/// <summary>Initializes a new instance of the <see cref="Currency" /> struct.</summary>
/// <param name="code">The code.</param>
/// <param name="number">The number.</param>
/// <param name="decimalDigits">The decimal digits.</param>
Expand Down Expand Up @@ -66,6 +64,10 @@ internal Currency(string code, string number, double decimalDigits, string engli
/// <value>The Currency that represents the country/region used by the current thread.</value>
public static Currency CurrentCurrency => FromRegion(RegionInfo.CurrentRegion);

/// <summary>Gets the currency sign (¤), a character used to denote an unspecified currency.</summary>
/// <remarks><seealso cref="https://en.wikipedia.org/wiki/Currency_sign_(typography)"/></remarks>
public static string CurrencySign => CultureInfo.InvariantCulture.NumberFormat.CurrencySymbol;

/// <summary>Gets the currency symbol.</summary>
public string Symbol { get; private set; }

Expand Down
4 changes: 3 additions & 1 deletion src/NodaMoney/CurrencyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ public static Currency Unregister(string code, string @namespace)
//// <exception cref="InvalidOperationException">The current CurrencyBuilder object has a property that must be set before the currency can be registered.</exception>
public Currency Build()
{
// TODO: Add validation?
// throw new InvalidOperationException("The current CurrencyBuilder object has a property that must be set before the currency can be registered.");
if (string.IsNullOrWhiteSpace(Symbol))
Symbol = Currency.CurrencySign;

var currency = new Currency(Code, ISONumber, DecimalDigits, EnglishName, Symbol, Namespace, ValidTo, ValidFrom);

return currency;
Expand Down
Loading

0 comments on commit ebba9fb

Please sign in to comment.