2021-03-30 01:17:58 +01:00
|
|
|
using System;
|
2021-04-07 01:27:35 +01:00
|
|
|
using System.Text.RegularExpressions;
|
2021-03-30 01:17:58 +01:00
|
|
|
|
2021-04-07 01:27:35 +01:00
|
|
|
public static class ReflectionExtensions
|
2021-03-30 01:17:58 +01:00
|
|
|
{
|
2021-04-07 01:27:35 +01:00
|
|
|
public static string SplitCamelCase( this string str )
|
|
|
|
|
{
|
|
|
|
|
return Regex.Replace(
|
|
|
|
|
Regex.Replace(
|
|
|
|
|
str,
|
|
|
|
|
@"(\P{Ll})(\P{Ll}\p{Ll})",
|
|
|
|
|
"$1 $2"
|
|
|
|
|
),
|
|
|
|
|
@"(\p{Ll})(\P{Ll})",
|
|
|
|
|
"$1 $2"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string FormatTypeName(this string typeName)
|
2021-03-30 01:17:58 +01:00
|
|
|
{
|
2021-04-18 05:13:20 +01:00
|
|
|
return (typeName.EndsWith("Data", StringComparison.InvariantCultureIgnoreCase)
|
2021-04-07 01:27:35 +01:00
|
|
|
? typeName.Substring(0, typeName.Length - 4)
|
|
|
|
|
: typeName).SplitCamelCase();
|
|
|
|
|
}
|
2026-06-16 19:19:05 +01:00
|
|
|
}
|