12345678910111213141516171819202122232425262728 |
- using System;
- using System.Linq;
- using System.Reflection;
-
- namespace Luticate2.Utils.Utils
- {
- public static class LuCoreUtilsExtensions
- {
- public static string ToSnakeCase(this string str)
- {
- if (str == null)
- {
- throw new ArgumentNullException(nameof(str));
- }
- return string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString())).ToLower();
- }
-
- public static Guid? ToGuid(this string str)
- {
- return str == null ? (Guid?)null : new Guid(str);
- }
-
- public static bool HasProperty(this Type type, string name)
- {
- return type.GetProperty(name) != null;
- }
- }
- }
|