v3.4.6
This commit is contained in:
@@ -31,7 +31,7 @@ public static class BooleanExtensions
|
||||
/// </summary>
|
||||
private static bool? GetBool(this object data)
|
||||
{
|
||||
switch (data.ToString()?.Trim().ToLower())
|
||||
switch (data.ToString().Trim().ToLower())
|
||||
{
|
||||
case "0":
|
||||
return false;
|
||||
|
||||
@@ -16,7 +16,7 @@ public static class DictionaryExtensions
|
||||
/// <param name="dictionary">要操作的字典.</param>
|
||||
/// <param name="key">指定键名.</param>
|
||||
/// <returns>获取到的值.</returns>
|
||||
public static TValue? GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
|
||||
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
|
||||
{
|
||||
return dictionary.TryGetValue(key, out TValue value) ? value : default(TValue);
|
||||
}
|
||||
|
||||
@@ -693,4 +693,25 @@ public static partial class Extensions
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region List
|
||||
|
||||
/// <summary>
|
||||
/// 嵌套List解析
|
||||
/// 仅限于列表查询条件多选.
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> ParseToNestedList(this List<List<string>> list)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
foreach (var item in list)
|
||||
result.Add(item.Last());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public static class RandomExtensions
|
||||
public static T NextItem<T>(this Random random, T[] items)
|
||||
{
|
||||
if (items == null || items.Length == 0)
|
||||
return default(T)!;
|
||||
return default(T);
|
||||
|
||||
return items[random.Next(items.Length)];
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ public static class StringExtensions
|
||||
/// 指示指定的字符串是 null、空或者仅由空白字符组成.
|
||||
/// </summary>
|
||||
[DebuggerStepThrough]
|
||||
public static bool IsNullOrWhiteSpace(this string value)
|
||||
public static bool IsNullOrWhiteSpace(this string? value)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user