Merge pull request #240 from tg44/bugfix

Fixed currency conversion error
This commit is contained in:
Master Kwoth 2016-04-27 21:00:46 +02:00
commit cf938a25d8
2 changed files with 18 additions and 3 deletions

6
.mono Normal file
View File

@ -0,0 +1,6 @@
# specify the build you want, either minimal (default) or full
# see below for explanation
MONO_TYPE=full
# if this is set, the cache is not used/cleaned.
# the cache is used to 1) store mono builds and 2) store nuget packages
MONO_CACHE=nope

View File

@ -92,6 +92,8 @@ namespace NadekoBot.Modules.Searches.Commands
}
else
{
CultureInfo ci = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = ci;
reInitCurrencyConverterTable();
Unit inUnit = currTable.CreateUnit(quantity, from.ToUpperInvariant());
Unit outUnit = inUnit.Convert(currTable.CurrencyCode(to.ToUpperInvariant()));
@ -108,11 +110,18 @@ namespace NadekoBot.Modules.Searches.Commands
private void reInitCurrencyConverterTable()
{
if (lastChanged == null || lastChanged.DayOfYear != DateTime.Now.DayOfYear)
{
try
{
exchangeRateProvider = new WebExchangeRatesProvider();
currTable = new CurrencyExchangeTable(exchangeRateProvider);
lastChanged = DateTime.Now;
}
catch
{
Console.WriteLine("Error with the currency download.");
}
}
}
private void ResolveUnitCodes(string from, string to, out UnitTable table, out int fromCode, out int toCode)