79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CadParamPluging.Common
|
|
{
|
|
public class DropdownOptions
|
|
{
|
|
public List<string> DeliveryStatuses { get; set; }
|
|
public List<string> ProcessMethods { get; set; }
|
|
public List<string> StructuralFeatures { get; set; }
|
|
public List<string> SpecialConditions { get; set; }
|
|
|
|
|
|
public DropdownOptions()
|
|
{
|
|
DeliveryStatuses = new List<string>();
|
|
ProcessMethods = new List<string>();
|
|
StructuralFeatures = new List<string>();
|
|
SpecialConditions = new List<string>();
|
|
}
|
|
|
|
public static DropdownOptions CreateDefault()
|
|
{
|
|
return new DropdownOptions
|
|
{
|
|
DeliveryStatuses = new List<string> { "毛料态", "车加工" },
|
|
ProcessMethods = new List<string> { "轧制", "自由锻" },
|
|
StructuralFeatures = new List<string> { "环形", "方体" },
|
|
SpecialConditions = new List<string> { "无", "中心冲孔", "非中心冲孔", "有圆头", "圆轴" }
|
|
};
|
|
}
|
|
|
|
public DropdownOptions Clone()
|
|
{
|
|
return new DropdownOptions
|
|
{
|
|
DeliveryStatuses = new List<string>(DeliveryStatuses ?? new List<string>()),
|
|
ProcessMethods = new List<string>(ProcessMethods ?? new List<string>()),
|
|
StructuralFeatures = new List<string>(StructuralFeatures ?? new List<string>()),
|
|
SpecialConditions = new List<string>(SpecialConditions ?? new List<string>())
|
|
};
|
|
}
|
|
|
|
public void Normalize()
|
|
{
|
|
DeliveryStatuses = NormalizeList(DeliveryStatuses);
|
|
ProcessMethods = NormalizeList(ProcessMethods);
|
|
StructuralFeatures = NormalizeList(StructuralFeatures);
|
|
SpecialConditions = NormalizeList(SpecialConditions);
|
|
}
|
|
|
|
private static List<string> NormalizeList(IEnumerable<string> values)
|
|
{
|
|
var result = new List<string>();
|
|
if (values == null)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
|
foreach (var raw in values)
|
|
{
|
|
var v = (raw ?? string.Empty).Trim();
|
|
if (v.Length == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (seen.Add(v))
|
|
{
|
|
result.Add(v);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|