using System; using System.Collections.Generic; namespace CadParamPluging.Common { public class DropdownOptions { public List DeliveryStatuses { get; set; } public List ProcessMethods { get; set; } public List StructuralFeatures { get; set; } public List SpecialConditions { get; set; } public DropdownOptions() { DeliveryStatuses = new List(); ProcessMethods = new List(); StructuralFeatures = new List(); SpecialConditions = new List(); } public static DropdownOptions CreateDefault() { return new DropdownOptions { DeliveryStatuses = new List { "毛料态", "车加工" }, ProcessMethods = new List { "轧制", "自由锻" }, StructuralFeatures = new List { "环形", "方体", "轴杆", "饼盘" }, SpecialConditions = new List { "无", "中心冲孔", "非中心冲孔", "有圆头", "圆轴", "方轴", "无圆头" } }; } public DropdownOptions Clone() { return new DropdownOptions { DeliveryStatuses = new List(DeliveryStatuses ?? new List()), ProcessMethods = new List(ProcessMethods ?? new List()), StructuralFeatures = new List(StructuralFeatures ?? new List()), SpecialConditions = new List(SpecialConditions ?? new List()) }; } public void Normalize() { DeliveryStatuses = NormalizeList(DeliveryStatuses); ProcessMethods = NormalizeList(ProcessMethods); StructuralFeatures = NormalizeList(StructuralFeatures); SpecialConditions = NormalizeList(SpecialConditions); } private static List NormalizeList(IEnumerable values) { var result = new List(); if (values == null) { return result; } var seen = new HashSet(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; } } }