|
|
@ -1,4 +1,5 @@
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
|
@ -29,6 +30,11 @@ public static class StringExtensions
|
|
|
|
public static string ToDashCase(this string str) =>
|
|
|
|
public static string ToDashCase(this string str) =>
|
|
|
|
Regex.Replace(str, @"(\p{Ll})(\p{Lu})", "$1-$2");
|
|
|
|
Regex.Replace(str, @"(\p{Ll})(\p{Lu})", "$1-$2");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static T? ParseEnumOrNull<T>(this string str, bool ignoreCase = true) where T : struct, Enum =>
|
|
|
|
|
|
|
|
Enum.TryParse<T>(str, ignoreCase, out var result)
|
|
|
|
|
|
|
|
? result
|
|
|
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
public static StringBuilder AppendIfNotEmpty(this StringBuilder builder, char value) =>
|
|
|
|
public static StringBuilder AppendIfNotEmpty(this StringBuilder builder, char value) =>
|
|
|
|
builder.Length > 0
|
|
|
|
builder.Length > 0
|
|
|
|
? builder.Append(value)
|
|
|
|
? builder.Append(value)
|
|
|
|