mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Add a fallback currency format info
This commit is contained in:
parent
365911286b
commit
011dd5574f
@ -47,8 +47,19 @@ namespace BTCPayServer.Services.Rates
|
||||
var data = GetCurrencyProvider(currency);
|
||||
if (data is NumberFormatInfo nfi)
|
||||
return nfi;
|
||||
return ((CultureInfo)data).NumberFormat;
|
||||
if (data is CultureInfo ci)
|
||||
return ci.NumberFormat;
|
||||
return CreateFallbackCurrencyFormatInfo(currency);
|
||||
}
|
||||
|
||||
private NumberFormatInfo CreateFallbackCurrencyFormatInfo(string currency)
|
||||
{
|
||||
var usd = GetNumberFormatInfo("USD");
|
||||
var currencyInfo = (NumberFormatInfo)usd.Clone();
|
||||
currencyInfo.CurrencySymbol = currency;
|
||||
return currencyInfo;
|
||||
}
|
||||
|
||||
public IFormatProvider GetCurrencyProvider(string currency)
|
||||
{
|
||||
lock (_CurrencyProviders)
|
||||
|
Loading…
Reference in New Issue
Block a user