Skip to content

Commit

Permalink
#27: Updated some helper classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinCelej committed May 14, 2023
1 parent fa1cc5f commit 580cc70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Synergy.Catalogue/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Synergy.Catalogue
{
#if INTERNAL_STRING_EXTENIONS
#if INTERNAL_STRING_EXTENIONS || INTERNALS
internal
#else
public
Expand All @@ -21,20 +21,20 @@ public static bool IsNullOrEmpty(this string text)
/// </summary>
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)
{
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])}");
// }
}
}
3 changes: 3 additions & 0 deletions Synergy.Catalogue/Reflection/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "<Clone>$");
}
}

0 comments on commit 580cc70

Please sign in to comment.