private void FindApiClientArg(EntityConfig friend, ApiItem item, ProjectConfig apiProject) { var entity = GetEntity(p => p != friend && p.ReferenceKey == friend.Key); var count = friend.Properties.Count(p => p.Name != "ClientNo"); switch (count) { case 0: item.ResultArg = null; if (entity != null) { entity.Option.IsDelete = true; } return; case 1: item.ResultArg = CppTypeHelper.CppTypeToCsType(friend.Properties.FirstOrDefault(p => p.Name != "ClientNo")); if (entity != null) { entity.Option.IsDelete = true; } return; } if (entity == null) { entity = new EntityConfig { Parent = apiProject, Project = apiProject.Name, CppName = item.CallArg, Name = ToClientName(item.CallArg), Tag = friend.Tag }; apiProject.Add(entity); } entity.NoDataBase = true; entity.ReferenceKey = friend.Key; entity.Caption = item.Caption + "命令调用参数"; entity.Description = item.Caption + "命令调用参数"; item.ResultArg = entity.Name; foreach (var property in friend.Properties) { var fp = entity.Properties.FirstOrDefault(p => p.ReferenceKey == property.Key) ?? entity.Properties.FirstOrDefault(p => p.Name == property.Name); if (fp == null) { fp = new PropertyConfig(); fp.CopyFrom(property); fp.Parent = entity; entity.Add(fp); } fp.Parent = entity; fp.Option.ReferenceKey = property.Option.Key; fp.Caption = property.Caption; fp.Tag = entity.Tag + "," + property.Name; } }
private void FindNitifyClientEntity(EntityConfig friend, ProjectConfig apiProject, NotifyItem item) { var entity = GetEntity(p => p != friend && p.Tag == friend.Tag); if (entity == null) { entity = new EntityConfig { Parent = apiProject, Project = apiProject.Name, CppName = friend.Name, Name = ToClientName(friend.Name), Caption = item.Caption, Description = item.Caption + "(消息通知)", NoDataBase = false, Classify = friend.Classify, ReferenceKey = friend.Key }; apiProject.Add(entity); } item.ClientEntity = entity.Name; if (entity.PrimaryColumn == null) { entity.Add(new PropertyConfig { Name = entity.Name + "Id", Caption = entity.Caption + "ID", Description = entity.Caption + "ID", IsPrimaryKey = true, IsIdentity = true, CsType = "int", CppType = "int", Parent = entity }); } foreach (var property in friend.Properties) { property.CsType = CppTypeHelper.CppTypeToCsType(property); property.Tag = friend.Tag + "," + property.Name; var fp = entity.Properties.FirstOrDefault(p => p.ReferenceKey == property.Key) ?? entity.Properties.FirstOrDefault(p => p.Name == property.Name); if (fp == null) { fp = new PropertyConfig(); fp.CopyFrom(property); fp.Parent = entity; entity.Add(fp); } fp.Parent = entity; fp.Tag = property.Tag; fp.ReferenceKey = property.Key; fp.Caption = property.Caption; } }
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); }