using Yw.Model;
|
|
namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 构件信息拓展
|
/// </summary>
|
public static class HydroParterInfoExtensions
|
{
|
/// <summary>
|
/// 匹配
|
/// </summary>
|
public static HydroSourceInfo Matching(this List<HydroSourceInfo> allSourceList, List<string> flags)
|
{
|
if (allSourceList == null || allSourceList.Count < 1)
|
{
|
return default;
|
}
|
allSourceList.ForEach(x =>
|
{
|
if (x.Flags == null)
|
{
|
x.Flags = new List<string>();
|
}
|
});
|
var sourceList = allSourceList.OrderBy(x => x.Flags.Distinct().Count()).ToList();
|
return sourceList.Find(x => x.Flags.ContainsC(flags));
|
}
|
|
/// <summary>
|
/// 匹配
|
/// </summary>
|
public static HydroNodeInfo Matching(this List<HydroNodeInfo> allNodeList, List<string> flags)
|
{
|
if (allNodeList == null || allNodeList.Count < 1)
|
{
|
return default;
|
}
|
allNodeList.ForEach(x =>
|
{
|
if (x.Flags == null)
|
{
|
x.Flags = new List<string>();
|
}
|
});
|
var nodeList = allNodeList.OrderBy(x => x.Flags.Distinct().Count()).ToList();
|
return nodeList.Find(x => x.Flags.ContainsC(flags));
|
}
|
|
/// <summary>
|
/// 匹配
|
/// </summary>
|
public static HydroLinkInfo Matching(this List<HydroLinkInfo> allLinkList, List<string> flags)
|
{
|
if (allLinkList == null || allLinkList.Count < 1)
|
{
|
return default;
|
}
|
allLinkList.ForEach(x =>
|
{
|
if (x.Flags == null)
|
{
|
x.Flags = new List<string>();
|
}
|
});
|
var linkList = allLinkList.OrderBy(x => x.Flags.Distinct().Count()).ToList();
|
return linkList.Find(x => x.Flags.ContainsC(flags));
|
}
|
|
|
}
|
}
|