merge with master
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
@@ -132,8 +132,8 @@ CurrencyDataLoader::CurrencyDataLoader(_In_ unique_ptr<ICurrencyHttpClient> clie
|
||||
m_ratioFormatter->IsDecimalPointAlwaysDisplayed = true;
|
||||
m_ratioFormatter->FractionDigits = FORMATTER_RATE_FRACTION_PADDING;
|
||||
|
||||
m_ratioFormat = AppResourceProvider::GetInstance().GetResourceString(L"CurrencyFromToRatioFormat")->Data();
|
||||
m_timestampFormat = AppResourceProvider::GetInstance().GetResourceString(L"CurrencyTimestampFormat")->Data();
|
||||
m_ratioFormat = AppResourceProvider::GetInstance()->GetResourceString(L"CurrencyFromToRatioFormat");
|
||||
m_timestampFormat = AppResourceProvider::GetInstance()->GetResourceString(L"CurrencyTimestampFormat");
|
||||
}
|
||||
|
||||
CurrencyDataLoader::~CurrencyDataLoader()
|
||||
@@ -300,16 +300,18 @@ pair<wstring, wstring> CurrencyDataLoader::GetCurrencyRatioEquality(_In_ const U
|
||||
double ratio = (iter2->second).ratio;
|
||||
double rounded = RoundCurrencyRatio(ratio);
|
||||
|
||||
wstring digitSymbol = wstring{ LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'1') };
|
||||
wstring roundedFormat = m_ratioFormatter->Format(rounded)->Data();
|
||||
auto digit = LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'1');
|
||||
auto digitSymbol = ref new String(&digit, 1);
|
||||
auto roundedFormat = m_ratioFormatter->Format(rounded);
|
||||
|
||||
wstring ratioString = LocalizationStringUtil::GetLocalizedString(
|
||||
m_ratioFormat.c_str(), digitSymbol.c_str(), unit1.abbreviation.c_str(), roundedFormat.c_str(), unit2.abbreviation.c_str());
|
||||
auto ratioString = LocalizationStringUtil::GetLocalizedString(
|
||||
m_ratioFormat, digitSymbol, StringReference(unit1.abbreviation.c_str()), roundedFormat, StringReference(unit2.abbreviation.c_str()));
|
||||
|
||||
wstring accessibleRatioString = LocalizationStringUtil::GetLocalizedString(
|
||||
m_ratioFormat.c_str(), digitSymbol.c_str(), unit1.accessibleName.c_str(), roundedFormat.c_str(), unit2.accessibleName.c_str());
|
||||
auto accessibleRatioString =
|
||||
LocalizationStringUtil::GetLocalizedString(
|
||||
m_ratioFormat, digitSymbol, StringReference(unit1.accessibleName.c_str()), roundedFormat, StringReference(unit2.accessibleName.c_str()));
|
||||
|
||||
return make_pair(ratioString, accessibleRatioString);
|
||||
return make_pair(ratioString->Data(), accessibleRatioString->Data());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -349,12 +351,12 @@ future<bool> CurrencyDataLoader::TryLoadDataFromCacheAsync()
|
||||
}
|
||||
catch (Exception ^ ex)
|
||||
{
|
||||
TraceLogger::GetInstance().LogPlatformException(ViewMode::Currency, __FUNCTIONW__, ex);
|
||||
TraceLogger::GetInstance()->LogPlatformException(ViewMode::Currency, __FUNCTIONW__, ex);
|
||||
co_return false;
|
||||
}
|
||||
catch (const exception& e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogStandardException(ViewMode::Currency, __FUNCTIONW__, e);
|
||||
TraceLogger::GetInstance()->LogStandardException(ViewMode::Currency, __FUNCTIONW__, e);
|
||||
co_return false;
|
||||
}
|
||||
catch (...)
|
||||
@@ -459,12 +461,12 @@ future<bool> CurrencyDataLoader::TryLoadDataFromWebAsync()
|
||||
}
|
||||
catch (Exception ^ ex)
|
||||
{
|
||||
TraceLogger::GetInstance().LogPlatformException(ViewMode::Currency, __FUNCTIONW__, ex);
|
||||
TraceLogger::GetInstance()->LogPlatformException(ViewMode::Currency, __FUNCTIONW__, ex);
|
||||
co_return false;
|
||||
}
|
||||
catch (const exception& e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogStandardException(ViewMode::Currency, __FUNCTIONW__, e);
|
||||
TraceLogger::GetInstance()->LogStandardException(ViewMode::Currency, __FUNCTIONW__, e);
|
||||
co_return false;
|
||||
}
|
||||
catch (...)
|
||||
@@ -480,7 +482,7 @@ future<bool> CurrencyDataLoader::TryLoadDataFromWebOverrideAsync()
|
||||
if (!didLoad)
|
||||
{
|
||||
m_loadStatus = CurrencyLoadStatus::FailedToLoad;
|
||||
TraceLogger::GetInstance().LogError(ViewMode::Currency, L"CurrencyDataLoader::TryLoadDataFromWebOverrideAsync", L"UserRequestedRefreshFailed");
|
||||
TraceLogger::GetInstance()->LogError(ViewMode::Currency, L"CurrencyDataLoader::TryLoadDataFromWebOverrideAsync", L"UserRequestedRefreshFailed");
|
||||
}
|
||||
|
||||
co_return didLoad;
|
||||
@@ -747,21 +749,19 @@ void CurrencyDataLoader::UpdateDisplayedTimestamp()
|
||||
}
|
||||
wstring CurrencyDataLoader::GetCurrencyTimestamp()
|
||||
{
|
||||
wstring timestamp = L"";
|
||||
|
||||
DateTime epoch{};
|
||||
if (m_cacheTimestamp.UniversalTime != epoch.UniversalTime)
|
||||
{
|
||||
DateTimeFormatter ^ dateFormatter = ref new DateTimeFormatter(L"{month.abbreviated} {day.integer}, {year.full}");
|
||||
wstring date = dateFormatter->Format(m_cacheTimestamp)->Data();
|
||||
DateTimeFormatter ^ dateFormatter = ref new DateTimeFormatter(L"shortdate");
|
||||
auto date = dateFormatter->Format(m_cacheTimestamp);
|
||||
|
||||
DateTimeFormatter ^ timeFormatter = ref new DateTimeFormatter(L"shorttime");
|
||||
wstring time = timeFormatter->Format(m_cacheTimestamp)->Data();
|
||||
auto time = timeFormatter->Format(m_cacheTimestamp);
|
||||
|
||||
timestamp = LocalizationStringUtil::GetLocalizedString(m_timestampFormat.c_str(), date.c_str(), time.c_str());
|
||||
return LocalizationStringUtil::GetLocalizedString(m_timestampFormat, date, time)->Data();
|
||||
}
|
||||
|
||||
return timestamp;
|
||||
return L"";
|
||||
}
|
||||
|
||||
#pragma optimize("", off) // Turn off optimizations to work around DevDiv 393321
|
||||
|
||||
@@ -124,9 +124,9 @@ namespace CalculatorApp
|
||||
std::shared_ptr<UCM::IViewModelCurrencyCallback> m_vmCallback;
|
||||
|
||||
Windows::Globalization::NumberFormatting::DecimalFormatter ^ m_ratioFormatter;
|
||||
std::wstring m_ratioFormat;
|
||||
Platform::String ^ m_ratioFormat;
|
||||
Windows::Foundation::DateTime m_cacheTimestamp;
|
||||
std::wstring m_timestampFormat;
|
||||
Platform::String ^ m_timestampFormat;
|
||||
|
||||
CurrencyLoadStatus m_loadStatus;
|
||||
|
||||
|
||||
@@ -953,7 +953,7 @@ void UnitConverterDataLoader::GetConversionData(_In_ unordered_map<ViewMode, uno
|
||||
|
||||
wstring UnitConverterDataLoader::GetLocalizedStringName(String ^ stringId)
|
||||
{
|
||||
return AppResourceProvider::GetInstance().GetResourceString(stringId)->Data();
|
||||
return AppResourceProvider::GetInstance()->GetResourceString(stringId)->Data();
|
||||
}
|
||||
|
||||
void UnitConverterDataLoader::GetExplicitConversionData(_In_ unordered_map<int, unordered_map<int, UCM::ConversionData>>& unitToUnitConversionList)
|
||||
|
||||
Reference in New Issue
Block a user