Binding convert looks at right culture setting (#15240)
* Binding convert looks at right culture setting * Update BindingExpressionTests.cs
This commit is contained in:
Родитель
7efdd2d79f
Коммит
b3600a2424
|
@ -123,7 +123,7 @@ namespace Xamarin.Forms.Core.UnitTests
|
|||
[TestCaseSource(nameof(TryConvertWithNumbersAndCulturesCases))]
|
||||
public void TryConvertWithNumbersAndCultures(object inputString, CultureInfo culture, object expected)
|
||||
{
|
||||
CultureInfo.CurrentUICulture = culture;
|
||||
CultureInfo.CurrentCulture = culture;
|
||||
BindingExpression.TryConvert(ref inputString, Entry.TextProperty, expected.GetType(), false);
|
||||
|
||||
Assert.AreEqual(expected, inputString);
|
||||
|
|
|
@ -2000,7 +2000,7 @@ namespace Xamarin.Forms.Core.UnitTests
|
|||
#if !WINDOWS_PHONE
|
||||
[TestCase("en-US", "0.5", 0.5, 0.9, "0.9")]
|
||||
[TestCase("pt-PT", "0,5", 0.5, 0.9, "0,9")]
|
||||
public void ConvertIsCultureInvariant(string culture, string sliderSetStringValue, double sliderExpectedDoubleValue, double sliderSetDoubleValue, string sliderExpectedStringValue)
|
||||
public void ConvertIsCultureAware(string culture, string sliderSetStringValue, double sliderExpectedDoubleValue, double sliderSetDoubleValue, string sliderExpectedStringValue)
|
||||
{
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
|
||||
|
||||
|
|
|
@ -1272,7 +1272,7 @@ namespace Xamarin.Forms.Core.UnitTests
|
|||
#if !WINDOWS_PHONE
|
||||
[TestCase("en-US", "0.5", 0.5, 0.9, "0.9")]
|
||||
[TestCase("pt-PT", "0,5", 0.5, 0.9, "0,9")]
|
||||
public void ConvertIsCultureInvariant(string culture, string sliderSetStringValue, double sliderExpectedDoubleValue, double sliderSetDoubleValue, string sliderExpectedStringValue)
|
||||
public void ConvertIsCultureAware(string culture, string sliderSetStringValue, double sliderExpectedDoubleValue, double sliderSetDoubleValue, string sliderExpectedStringValue)
|
||||
{
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
|
||||
|
||||
|
|
|
@ -462,7 +462,7 @@ namespace Xamarin.Forms
|
|||
var stringValue = value as string ?? string.Empty;
|
||||
// see: https://bugzilla.xamarin.com/show_bug.cgi?id=32871
|
||||
// do not canonicalize "*.[.]"; "1." should not update bound BindableProperty
|
||||
if (stringValue.EndsWith(CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator, StringComparison.Ordinal) && DecimalTypes.Contains(convertTo))
|
||||
if (stringValue.EndsWith(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, StringComparison.Ordinal) && DecimalTypes.Contains(convertTo))
|
||||
{
|
||||
value = original;
|
||||
return false;
|
||||
|
@ -475,7 +475,7 @@ namespace Xamarin.Forms
|
|||
return false;
|
||||
}
|
||||
|
||||
value = Convert.ChangeType(value, convertTo, CultureInfo.CurrentUICulture);
|
||||
value = Convert.ChangeType(value, convertTo, CultureInfo.CurrentCulture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче