Optimizing and improving code

This commit is contained in:
2dust
2025-07-20 14:16:19 +08:00
parent 6a17c539d1
commit 569e939492
22 changed files with 164 additions and 441 deletions
@@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis;
namespace ServiceLib.Common;
public static class StringEx
public static class Extension
{
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value)
{
@@ -79,4 +79,9 @@ public static class StringEx
{
return int.TryParse(value, out var result) ? result : defaultValue;
}
public static List<string> AppendEmpty(this IEnumerable<string> source)
{
return source.Concat(new[] { string.Empty }).ToList();
}
}
+8
View File
@@ -323,6 +323,14 @@ public class Utils
return text.Replace(",", ",").Replace(Environment.NewLine, ",");
}
public static List<string> GetEnumNames<TEnum>() where TEnum : Enum
{
return Enum.GetValues(typeof(TEnum))
.Cast<TEnum>()
.Select(e => e.ToString())
.ToList();
}
#endregion 转换函数
#region 数据检查