mirror of
https://github.com/stokebob/BealeEngineering.git
synced 2026-03-21 07:37:16 +00:00
62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BealeEngineering.Core.Data
|
|
{
|
|
public class CurrencyFormat
|
|
{
|
|
Dictionary<string, string> dictionarySymbol = new Dictionary<string, string>();
|
|
Dictionary<string, string> dictionaryCulture = new Dictionary<string, string>();
|
|
public CurrencyFormat()
|
|
{
|
|
dictionarySymbol.Add("GBP", "£");
|
|
dictionarySymbol.Add("EUR", "€");
|
|
dictionarySymbol.Add("USD", "$");
|
|
|
|
dictionaryCulture.Add("GBP", "en-GB");
|
|
dictionaryCulture.Add("EUR", "fr-FR");
|
|
dictionaryCulture.Add("USD", "en-US");
|
|
}
|
|
|
|
public string ReadCurrencySymbol(string currencyCode)
|
|
{
|
|
if (dictionarySymbol.ContainsKey(currencyCode))
|
|
{
|
|
return dictionarySymbol[currencyCode];
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Invalid currency code.");
|
|
}
|
|
}
|
|
|
|
public string ReadCultureString(string currencyCode)
|
|
{
|
|
if (dictionaryCulture.ContainsKey(currencyCode))
|
|
{
|
|
return dictionaryCulture[currencyCode];
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Invalid currency code.");
|
|
}
|
|
}
|
|
|
|
public CultureInfo ReadCulture(string currencyCode)
|
|
{
|
|
if (dictionaryCulture.ContainsKey(currencyCode))
|
|
{
|
|
return new CultureInfo(dictionaryCulture[currencyCode]);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Invalid currency code.");
|
|
}
|
|
}
|
|
}
|
|
}
|