public static EnumConfig RepairByTypedef(ProjectConfig project, TypedefItem type) { var enumcfg = SolutionConfig.Current.Enums.FirstOrDefault(p => p.Option.ReferenceKey == type.Key); if (enumcfg != null) { if (type.Items.Count == 0) { enumcfg.Option.IsDelete = true; return(null); } FindEnumOld(type, enumcfg); return(enumcfg); } if (type.Items.Count == 0) { return(null); } string name = type.Name; if (type.Name[0] == 'T') { name = type.Name.Substring(1); } var words = ToWords(name, true); while (words.Last() == "Type") { words.RemoveAt(words.Count - 1); } name = words.LinkToString() + "Type"; enumcfg = SolutionConfig.Current.Enums.FirstOrDefault(p => p.Name == name); if (enumcfg != null) { FindEnumOld(type, enumcfg); return(enumcfg); } enumcfg = new EnumConfig { Name = name, Caption = type.Caption.Replace("类型", "") + "类型", Description = type.Description.Replace("类型", "") + "类型", Items = new ObservableCollection <EnumItem>() }; int id = 0; var name_head = words.LinkToString(); foreach (var item in type.Items.Values) { var eitem = new EnumItem { Name = ToWords(item.Name.ToLower(), true).LinkToString().Replace(name_head, "").Replace("Type", ""), Caption = item.Caption, Value = (++id).ToString() }; enumcfg.Add(eitem); eitem.Option.ReferenceKey = item.Key; } enumcfg.Option.ReferenceKey = type.Key; project.Add(enumcfg); return(enumcfg); }