From 580cc70cdd8fc9d9212dee225619abce0a50a471 Mon Sep 17 00:00:00 2001 From: Marcin Celej Date: Sun, 14 May 2023 10:29:05 +0200 Subject: [PATCH] #27: Updated some helper classes --- Synergy.Catalogue/Extensions/StringExtensions.cs | 14 +++++++------- .../Reflection/ReflectionExtensions.cs | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Synergy.Catalogue/Extensions/StringExtensions.cs b/Synergy.Catalogue/Extensions/StringExtensions.cs index 281ae34..cc5a581 100644 --- a/Synergy.Catalogue/Extensions/StringExtensions.cs +++ b/Synergy.Catalogue/Extensions/StringExtensions.cs @@ -3,7 +3,7 @@ namespace Synergy.Catalogue { -#if INTERNAL_STRING_EXTENIONS +#if INTERNAL_STRING_EXTENIONS || INTERNALS internal #else public @@ -21,10 +21,10 @@ public static bool IsNullOrEmpty(this string text) /// public static string? TrimToNull(this string? text) { - if (text.IsNullOrWhiteSpace()) + if (String.IsNullOrWhiteSpace(text)) return null; - return text?.Trim(); + return text.Trim(); } public static string Left(this string text, int length) @@ -32,9 +32,9 @@ public static string Left(this string text, int length) return length > text.Length ? text : text.Substring(0, length); } - public static string CamelCaseToSentence(string input) - { - return Regex.Replace(input, "[a-z][A-Z]", m => $"{m.Value[0]} {char.ToLower(m.Value[1])}"); - } + // public static string CamelCaseToSentence(string input) + // { + // return Regex.Replace(input, "[a-z][A-Z]", m => $"{m.Value[0]} {char.ToLower(m.Value[1])}"); + // } } } \ No newline at end of file diff --git a/Synergy.Catalogue/Reflection/ReflectionExtensions.cs b/Synergy.Catalogue/Reflection/ReflectionExtensions.cs index 0971254..47ce1b3 100644 --- a/Synergy.Catalogue/Reflection/ReflectionExtensions.cs +++ b/Synergy.Catalogue/Reflection/ReflectionExtensions.cs @@ -114,5 +114,8 @@ public static string GetFriendlyMethodName(this MethodInfo method) { return $"{method.Name}({String.Join(", ", method.GetParameters().Select(p => p.ParameterType.GetFriendlyTypeName()))})"; } + + public static bool IsRecord(this Type type) + => type.GetMethods(BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public).Any(m => m.Name == "$"); } } \ No newline at end of file