diff --git a/src/Calculator.Droid/Calculator.Droid.csproj b/src/Calculator.Droid/Calculator.Droid.csproj
index 16d40f4d..9181501b 100644
--- a/src/Calculator.Droid/Calculator.Droid.csproj
+++ b/src/Calculator.Droid/Calculator.Droid.csproj
@@ -63,11 +63,14 @@
+
+ 12.0.2
+
-
-
-
+
+
+
Properties\AssemblyVersion.Android.cs
@@ -197,4 +200,4 @@
-->
-
+
\ No newline at end of file
diff --git a/src/Calculator.Shared/Common/LocalizationStringUtil.cs b/src/Calculator.Shared/Common/LocalizationStringUtil.cs
index 6f39a640..6c61edc2 100644
--- a/src/Calculator.Shared/Common/LocalizationStringUtil.cs
+++ b/src/Calculator.Shared/Common/LocalizationStringUtil.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
@@ -14,33 +15,13 @@ namespace CalculatorApp
{
public static string GetLocalizedString(string pMessage, params object[] args)
{
- var stringBuilder = new StringBuilder(pMessage);
-
- // This will capture all % strings
- var matches = Regex
- .Matches(pMessage, @"%(\d+)")
- .AsEnumerable()
- .OrderBy(str => str.Value.Replace("%", ""));
-
- // If our starting index begin at 1, we will decrease all of them in order to use string.Format
- if (matches.FirstOrDefault()?.Value == "%1")
+ if (pMessage == null)
{
- var addedCharacterFromOriginal = 0;
-
- foreach (var match in matches)
- {
- if(int.TryParse(match.Value.Replace("%", ""), out var argumentIndex))
- {
- stringBuilder.Remove(match.Index + addedCharacterFromOriginal, match.Length);
- stringBuilder.Insert(match.Index + addedCharacterFromOriginal, "{" + (argumentIndex - 1).ToString() + "}");
- // Since we are replace % by {}, we will add one character for each iteration
- // so we need to consider that
- addedCharacterFromOriginal++;
- }
- }
+ return string.Empty;
}
- return $"{string.Format(stringBuilder.ToString(), args)}";
+ var pattern = Regex.Replace(pMessage, @"%(?\d+)", m => "{" + (int.Parse(m.Groups["number"].Value) - 1) + "}");
+ return string.Format(CultureInfo.CurrentCulture, pattern, args);
}
public static string GetLocalizedNarratorAnnouncement(string resourceKey, string formatVariable, params object[] args)
diff --git a/src/Calculator.Shared/DataLoaders/CurrencyDataLoader.cs b/src/Calculator.Shared/DataLoaders/CurrencyDataLoader.cs
index 933743bd..d70122ea 100644
--- a/src/Calculator.Shared/DataLoaders/CurrencyDataLoader.cs
+++ b/src/Calculator.Shared/DataLoaders/CurrencyDataLoader.cs
@@ -123,12 +123,12 @@ namespace CalculatorApp.ViewModel
static string FROM_KEY = "from";
static string TO_KEY = "to";
+ private static string DefaultCurrencyCode = LocalizationService.DefaultCurrencyCode;
+
// Fallback default values.
static string DEFAULT_FROM_CURRENCY = DefaultCurrencyCode;
static string DEFAULT_TO_CURRENCY = "EUR";
- private static string DefaultCurrencyCode = LocalizationService.DefaultCurrencyCode;
-
public CurrencyDataLoader(ICurrencyHttpClient client)
{
this.m_client = client;
@@ -507,6 +507,7 @@ namespace CalculatorApp.ViewModel
bool TryParseStaticData(String rawJson, CalculatorList staticData)
{
+#if NETFX_CORE // TODO UNO
JsonArray data = null;
if (!JsonArray.TryParse(rawJson, out data))
{
@@ -519,7 +520,7 @@ namespace CalculatorApp.ViewModel
string currencyName = "";
string currencySymbol = "";
- string[] values = {countryCode, countryName, currencyCode, currencyName, currencySymbol};
+ string[] values = { countryCode, countryName, currencyCode, currencyName, currencySymbol };
Debug.Assert(values.Length == STATIC_DATA_PROPERTIES.Length);
staticData.Clear();
@@ -540,10 +541,36 @@ namespace CalculatorApp.ViewModel
staticData.Sort((UCM.CurrencyStaticData unit1, UCM.CurrencyStaticData unit2) => { return unit1.countryName.CompareTo(unit2.countryName) < 0; });
return true;
+#else
+ try
+ {
+ var items = Newtonsoft.Json.JsonConvert.DeserializeObject(rawJson);
+ staticData.Clear();
+ foreach (var item in items)
+ {
+ staticData.Add(item);
+ }
+ staticData.Sort((UCM.CurrencyStaticData unit1, UCM.CurrencyStaticData unit2) => { return unit1.countryName.CompareTo(unit2.countryName) < 0; });
+
+ return true;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+#endif
+ }
+
+ public class JsonCurrencyRatio
+ {
+ public double Rt { get; set; }
+
+ public string An { get; set; }
}
public bool TryParseAllRatiosData(String rawJson, CurrencyRatioMap allRatios)
{
+#if NETFX_CORE // TODO UNO
JsonArray data = null;
if (!JsonArray.TryParse(rawJson, out data))
{
@@ -565,6 +592,26 @@ namespace CalculatorApp.ViewModel
}
return true;
+#else
+ try
+ {
+ string sourceCurrencyCode = DefaultCurrencyCode;
+
+ var items = Newtonsoft.Json.JsonConvert.DeserializeObject(rawJson);
+ allRatios.Clear();
+ foreach (var item in items)
+ {
+ allRatios.Add(item.An, new UCM.CurrencyRatio(item.Rt, sourceCurrencyCode, item.An));
+ }
+
+ return true;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+
+#endif
}
// FinalizeUnits
@@ -712,11 +759,15 @@ namespace CalculatorApp.ViewModel
DateTime epoch = default(DateTime);
if (m_cacheTimestamp.ToUniversalTime() != epoch.ToUniversalTime())
{
- DateTimeFormatter dateFormatter = new DateTimeFormatter("{month.abbreviated} {day.integer}, {year.full}");
- string date = dateFormatter.Format(m_cacheTimestamp);
+ // TODO UNO
+ //DateTimeFormatter dateFormatter = new DateTimeFormatter("{month.abbreviated} {day.integer}, {year.full}");
+ //string date = dateFormatter.Format(m_cacheTimestamp);
+ var date = m_cacheTimestamp.ToString("D");
- DateTimeFormatter timeFormatter = new DateTimeFormatter("shorttime");
- string time = timeFormatter.Format(m_cacheTimestamp);
+ // TODO UNO
+ //DateTimeFormatter timeFormatter = new DateTimeFormatter("shorttime");
+ //string time = timeFormatter.Format(m_cacheTimestamp);
+ var time = m_cacheTimestamp.ToString("t");
timestamp = LocalizationStringUtil.GetLocalizedString(m_timestampFormat, date, time);
}
diff --git a/src/Calculator.Shared/DataLoaders/CurrencyHttpClient.cs b/src/Calculator.Shared/DataLoaders/CurrencyHttpClient.cs
index 8472e6bf..9a48113c 100644
--- a/src/Calculator.Shared/DataLoaders/CurrencyHttpClient.cs
+++ b/src/Calculator.Shared/DataLoaders/CurrencyHttpClient.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Text;
+using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Web.Http;
@@ -11,7 +12,8 @@ namespace CalculatorApp.DataLoaders
{
public class CurrencyHttpClient : ICurrencyHttpClient
{
- Windows.Web.Http.HttpClient m_client;
+ // TODO UNO: Windows.Web.Http.HttpClient
+ System.Net.Http.HttpClient m_client;
string m_responseLanguage;
string m_sourceCurrencyCode;
@@ -20,7 +22,7 @@ namespace CalculatorApp.DataLoaders
public CurrencyHttpClient()
{
- m_client = new HttpClient();
+ m_client = new System.Net.Http.HttpClient();
m_responseLanguage = "en-US";
}
@@ -34,7 +36,7 @@ namespace CalculatorApp.DataLoaders
m_responseLanguage = responseLanguage;
}
- public IAsyncOperationWithProgress GetCurrencyMetadata()
+ public Task GetCurrencyMetadata()
{
string uri = sc_MetadataUriLocalizeFor + m_responseLanguage;
var metadataUri = new Uri(uri);
@@ -42,7 +44,7 @@ namespace CalculatorApp.DataLoaders
return m_client.GetStringAsync(metadataUri);
}
- public IAsyncOperationWithProgress GetCurrencyRatios()
+ public Task GetCurrencyRatios()
{
string uri = sc_RatiosUriRelativeTo + m_sourceCurrencyCode;
var ratiosUri = new Uri(uri);
diff --git a/src/Calculator.Shared/DataLoaders/ICurrencyHttpClient.cs b/src/Calculator.Shared/DataLoaders/ICurrencyHttpClient.cs
index cf4a18f9..8c6170ee 100644
--- a/src/Calculator.Shared/DataLoaders/ICurrencyHttpClient.cs
+++ b/src/Calculator.Shared/DataLoaders/ICurrencyHttpClient.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Text;
+using System.Threading.Tasks;
namespace CalculatorApp.DataLoaders
{
@@ -12,7 +13,7 @@ namespace CalculatorApp.DataLoaders
void SetSourceCurrencyCode(string sourceCurrencyCode);
void SetResponseLanguage(string responseLanguage);
- Windows.Foundation.IAsyncOperationWithProgress GetCurrencyMetadata();
- Windows.Foundation.IAsyncOperationWithProgress GetCurrencyRatios();
+ Task GetCurrencyMetadata();
+ Task GetCurrencyRatios();
}
}
diff --git a/src/Calculator.Wasm/Calculator.Wasm.csproj b/src/Calculator.Wasm/Calculator.Wasm.csproj
index 74b4199f..450406ca 100644
--- a/src/Calculator.Wasm/Calculator.Wasm.csproj
+++ b/src/Calculator.Wasm/Calculator.Wasm.csproj
@@ -8,7 +8,7 @@
NU1701
false
true
- FullAOT
+ InterpreterAndAOT
release-dynamic
@@ -43,10 +43,15 @@
+
+
+
+
+
diff --git a/src/Calculator.iOS/Calculator.iOS.csproj b/src/Calculator.iOS/Calculator.iOS.csproj
index 2fe81c24..0a2b0695 100644
--- a/src/Calculator.iOS/Calculator.iOS.csproj
+++ b/src/Calculator.iOS/Calculator.iOS.csproj
@@ -205,10 +205,13 @@
+
+ 12.0.2
+
-
-
-
+
+
+
Static
@@ -224,4 +227,4 @@
-
+
\ No newline at end of file