Skip to content

Commit fd76f50

Browse files
committed
chore: minor improvements
1 parent f490f9a commit fd76f50

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

ObjectSemantics.NET/Engine/Extensions/ExtractedObjPropertyExtensions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ private static string GetAppliedPropertyFormatting(this ExtractedObjProperty p,
3131

3232
// avoid repeated ToLower calls
3333
string fmt = customFormat.Trim();
34-
string fmtLower = fmt.ToLowerInvariant();
35-
3634
// handle numeric and datetime formats first
3735
try
3836
{
@@ -55,7 +53,7 @@ private static string GetAppliedPropertyFormatting(this ExtractedObjProperty p,
5553
}
5654

5755
// custom string-based formats (single switch to avoid multiple ToLower() checks)
58-
switch (fmtLower)
56+
switch (fmt.ToLowerInvariant())
5957
{
6058
case "uppercase": return val?.ToUpperInvariant();
6159
case "lowercase": return val?.ToLowerInvariant();
@@ -102,8 +100,7 @@ public static bool IsPropertyValueConditionPassed(this ExtractedObjProperty prop
102100
}
103101
}
104102

105-
if (t == typeof(int) || t == typeof(double) || t == typeof(long) ||
106-
t == typeof(float) || t == typeof(decimal))
103+
if (t == typeof(int) || t == typeof(double) || t == typeof(long) || t == typeof(float) || t == typeof(decimal))
107104
{
108105
double v1 = Convert.ToDouble(original ?? 0, CultureInfo.InvariantCulture);
109106
double v2 = Convert.ToDouble(GetConvertibleValue<double>(valueComparer), CultureInfo.InvariantCulture);

ObjectSemantics.NET/Engine/Extensions/StringExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Globalization;
23
using System.Text;
34

45
namespace ObjectSemantics.NET.Engine.Extensions
@@ -36,7 +37,7 @@ public static string ToMD5String(this string input)
3637
// Convert the byte array to hexadecimal string
3738
StringBuilder sb = new StringBuilder();
3839
for (int i = 0; i < hashBytes.Length; i++)
39-
sb.Append(hashBytes[i].ToString("X2"));
40+
sb.Append(hashBytes[i].ToString("X2", CultureInfo.InvariantCulture));
4041
return sb.ToString();
4142
}
4243
}

ObjectSemantics.NET/Engine/Models/ExtractedObjProperty.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections;
3+
using System.Globalization;
34

45
namespace ObjectSemantics.NET.Engine.Models
56
{
@@ -8,7 +9,8 @@ internal class ExtractedObjProperty
89
public Type Type { get; set; }
910
public string Name { get; set; }
1011
public object OriginalValue { get; set; }
11-
public string StringFormatted { get { return string.Format("{0}", OriginalValue); } }
12+
public string StringFormatted => Convert.ToString(OriginalValue, CultureInfo.InvariantCulture);
13+
1214
public bool IsEnumerableObject
1315
{
1416
get { return typeof(IEnumerable).IsAssignableFrom(Type) && Type != typeof(string); }

0 commit comments

Comments
 (0)