diff --git a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
index f272484611..5fe47112ba 100644
--- a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
@@ -260,8 +260,9 @@ namespace System
///
/// String to convert
/// set true to use current culture. Otherwise, invariant culture will be used.
+ /// set true to if you want to convert 'XYZ' to 'xyz'.
/// camelCase of the string
- public static string ToCamelCase(this string str, bool useCurrentCulture = false)
+ public static string ToCamelCase(this string str, bool useCurrentCulture = false, bool handleAbbreviations = false)
{
if (string.IsNullOrWhiteSpace(str))
{
@@ -273,6 +274,11 @@ namespace System
return useCurrentCulture ? str.ToLower() : str.ToLowerInvariant();
}
+ if (handleAbbreviations && IsAllUpperCase(str))
+ {
+ return useCurrentCulture ? str.ToLower() : str.ToLowerInvariant();
+ }
+
return (useCurrentCulture ? char.ToLower(str[0]) : char.ToLowerInvariant(str[0])) + str.Substring(1);
}
@@ -545,5 +551,18 @@ namespace System
return encoding.GetBytes(str);
}
+
+ private static bool IsAllUpperCase(string input)
+ {
+ for (int i = 0; i < input.Length; i++)
+ {
+ if (Char.IsLetter(input[i]) && !Char.IsUpper(input[i]))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
}