2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public static class IEnumerableHelper
|
|
|
|
|
{
|
2021-04-13 20:39:32 +08:00
|
|
|
|
public static string ToCustomString<T>(this IEnumerable<T> list)
|
|
|
|
|
{
|
|
|
|
|
string str = null;
|
|
|
|
|
foreach (T item in list)
|
|
|
|
|
{
|
|
|
|
|
if(item == null)
|
|
|
|
|
{
|
|
|
|
|
str += "【none】";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
str += $"【{item}】";
|
|
|
|
|
}
|
|
|
|
|
str ??= "无";
|
|
|
|
|
return str;
|
|
|
|
|
}
|
2021-04-08 20:09:59 +08:00
|
|
|
|
public static string ToCustomString(this IEnumerable<Unit> list)
|
|
|
|
|
{
|
|
|
|
|
string str = null;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Unit item in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if(item == null)
|
|
|
|
|
{
|
|
|
|
|
str += "【none】";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
str += $"【{UserComponent.Instance.Get(item.Id)?.NickName}({item.Id})】";
|
|
|
|
|
}
|
|
|
|
|
str ??= "无";
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
public static string ToCustomString(this Dictionary<int,long> list)
|
|
|
|
|
{
|
|
|
|
|
string str = null;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (KeyValuePair<int, long> item in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
str += $"【{item.Key},{item.Value}】";
|
|
|
|
|
}
|
|
|
|
|
str ??= "无";
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|