|
@@ -2,6 +2,7 @@
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace XF.Domain.Extensions
|
|
@@ -10,6 +11,8 @@ namespace XF.Domain.Extensions
|
|
|
{
|
|
|
public static string ToSnakeCase(this string name)
|
|
|
{
|
|
|
+ if (string.IsNullOrEmpty(name))
|
|
|
+ throw new ArgumentNullException(nameof(name));
|
|
|
var sb = new StringBuilder();
|
|
|
sb.Append(char.ToLower(name[0]));
|
|
|
for (int i = 1; i < name.Length; i++)
|
|
@@ -26,5 +29,17 @@ namespace XF.Domain.Extensions
|
|
|
}
|
|
|
return sb.ToString();
|
|
|
}
|
|
|
+
|
|
|
+ public static string UpperFirstChar(this string str)
|
|
|
+ {
|
|
|
+ if(string.IsNullOrEmpty(str))
|
|
|
+ throw new ArgumentNullException(nameof(str));
|
|
|
+ var firstChar = str[0];
|
|
|
+ if (char.IsUpper(firstChar))
|
|
|
+ return str;
|
|
|
+ firstChar = char.ToUpper(firstChar);
|
|
|
+ str = str.Remove(0, 1);
|
|
|
+ return str.Insert(0,firstChar.ToString());
|
|
|
+ }
|
|
|
}
|
|
|
}
|