mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 22:56:32 +00:00
4bc76bbbac
add getusers tidy up BusinessException
28 lines
697 B
C#
28 lines
697 B
C#
using System.Text;
|
|
|
|
namespace Azaion.Common.Extensions;
|
|
|
|
public static class StringExtensions
|
|
{
|
|
public static string ToSnakeCase(this string text)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
return text;
|
|
|
|
if (text.Length < 2)
|
|
return text.ToLowerInvariant();
|
|
|
|
var sb = new StringBuilder();
|
|
sb.Append(char.ToLowerInvariant(text[0]));
|
|
for (int i = 1; i < text.Length; ++i) {
|
|
var c = text[i];
|
|
if(char.IsUpper(c)) {
|
|
sb.Append('_');
|
|
sb.Append(char.ToLowerInvariant(c));
|
|
} else {
|
|
sb.Append(c);
|
|
}
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
} |