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 { "A1", "A3" }, 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; } } }