Skip to content

Commit

Permalink
Added missing Format method for decimal amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
pruiz committed May 13, 2016
1 parent 7123aa7 commit bbae529
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions HermaFx.Foundation/Globalization/Currency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static NumberFormatInfo GetNumberFormatInfo()
return _cleanNumberFormatInfos[culture.Name];
}

private string Format(IFormatProvider provider, decimal amount, bool hideSymbol)
private string FormatInternal(IFormatProvider provider, decimal amount, bool hideSymbol)
{
provider = provider ?? GetNumberFormatInfo();

Expand All @@ -57,21 +57,23 @@ private string Format(IFormatProvider provider, decimal amount, bool hideSymbol)
: string.Format(provider, "{0} {1:c}", Symbol, amount);
}

public string Format(IFormatProvider provider, short amount, bool hideSymbol = false) => Format(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, ushort amount, bool hideSymbol = false) => Format(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, int amount, bool hideSymbol = false) => Format(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, uint amount, bool hideSymbol = false) => Format(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, long amount, bool hideSymbol = false) => Format(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, ulong amount, bool hideSymbol = false) => Format(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, double amount, bool hideSymbol = false) => Format(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, short amount, bool hideSymbol = false) => FormatInternal(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, ushort amount, bool hideSymbol = false) => FormatInternal(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, int amount, bool hideSymbol = false) => FormatInternal(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, uint amount, bool hideSymbol = false) => FormatInternal(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, long amount, bool hideSymbol = false) => FormatInternal(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, ulong amount, bool hideSymbol = false) => FormatInternal(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, double amount, bool hideSymbol = false) => FormatInternal(provider, Convert.ToDecimal(amount), hideSymbol);
public string Format(IFormatProvider provider, decimal amount, bool hideSymbol = false) => FormatInternal(provider, amount, hideSymbol);

public string Format(short amount, bool hideSymbol = false) => Format(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(ushort amount, bool hideSymbol = false) => Format(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(int amount, bool hideSymbol = false) => Format(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(uint amount, bool hideSymbol = false) => Format(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(long amount, bool hideSymbol = false) => Format(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(ulong amount, bool hideSymbol = false) => Format(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(double amount, bool hideSymbol = false) => Format(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(short amount, bool hideSymbol = false) => FormatInternal(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(ushort amount, bool hideSymbol = false) => FormatInternal(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(int amount, bool hideSymbol = false) => FormatInternal(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(uint amount, bool hideSymbol = false) => FormatInternal(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(long amount, bool hideSymbol = false) => FormatInternal(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(ulong amount, bool hideSymbol = false) => FormatInternal(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(double amount, bool hideSymbol = false) => FormatInternal(null, Convert.ToDecimal(amount), hideSymbol);
public string Format(decimal amount, bool hideSymbol = false) => FormatInternal(null, amount, hideSymbol);

#endregion

Expand Down

0 comments on commit bbae529

Please sign in to comment.