From ee01592b9968a049ab46307e983a92f535dbf036 Mon Sep 17 00:00:00 2001 From: Roger Arbogast Date: Fri, 21 Feb 2025 17:16:53 +0100 Subject: [PATCH] FIX: Use culture in converters where possible --- src/ValueConverters/StringFormatConverter.cs | 6 +++--- src/ValueConverters/ToLowerConverter.cs | 2 +- src/ValueConverters/ToUpperConverter.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ValueConverters/StringFormatConverter.cs b/src/ValueConverters/StringFormatConverter.cs index ebfc325d..3062da2b 100644 --- a/src/ValueConverters/StringFormatConverter.cs +++ b/src/ValueConverters/StringFormatConverter.cs @@ -35,12 +35,12 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur // try to load SmartFormat Assembly var asSmartFormat = Assembly.Load("SmartFormat"); var tt = asSmartFormat.GetType("SmartFormat.Smart"); - miFormat = tt.GetMethod("Format", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string), typeof(object[]) }, null); + miFormat = tt.GetMethod("Format", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(IFormatProvider), typeof(string), typeof(object[]) }, null); } catch { // fallback just take String.Format - miFormat = typeof(string).GetMethod("Format", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string), typeof(object[]) }, null); + miFormat = typeof(string).GetMethod("Format", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(IFormatProvider), typeof(string), typeof(object[]) }, null); } } @@ -61,7 +61,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur return format; var args = values.Skip(1).ToArray(); - return (string)miFormat.Invoke(null, new object[] { format, args }); + return (string)miFormat.Invoke(null, new object[] { culture, format, args }); } /// diff --git a/src/ValueConverters/ToLowerConverter.cs b/src/ValueConverters/ToLowerConverter.cs index c8eb29ae..c9253c71 100644 --- a/src/ValueConverters/ToLowerConverter.cs +++ b/src/ValueConverters/ToLowerConverter.cs @@ -30,7 +30,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn { if (value != null) { - return value.ToString().ToLower(); + return value.ToString().ToLower(culture); } return null; diff --git a/src/ValueConverters/ToUpperConverter.cs b/src/ValueConverters/ToUpperConverter.cs index affa16c1..b2ee1a58 100644 --- a/src/ValueConverters/ToUpperConverter.cs +++ b/src/ValueConverters/ToUpperConverter.cs @@ -30,7 +30,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn { if (value != null) { - return value.ToString().ToUpper(); + return value.ToString().ToUpper(culture); } return null;