public bool GeneCs(string xmlPath, string outPutDir) { try { Console.WriteLine("Generate Language"); TableData td = xParser.GetTableData(Path.GetFileNameWithoutExtension(xmlPath), FileOpt.ReadTextFromFile(xmlPath)); string content = GetSharpHeader(); List <string> except = new List <string>(); foreach (SheetData sd in td.sheets) { foreach (RowData rd in sd.dataRows) { var summary = GetSummary(rd); var ltk = GetLTKey(rd); if (!string.IsNullOrEmpty(ltk)) { content += GetSharpRowStr(ltk, summary); } } except.Add(sd.name); } content += "\t}\n}\n"; FileOpt.WriteText(content, outPutDir + "LTKey.cs"); return(true); } catch (Exception e) { Console.WriteLine(e.ToString()); return(false); } }
/// <summary> /// 根据PropertiesList文件,获取配置文件名的List /// </summary> /// <param name="filePath"></param> /// <param name="fileType"></param> /// <returns></returns> private string[] GetPropertiesList(string filePath, string fileType) { string text = FileOpt.ReadTextFromFile(filePath); text = text.Replace("\r", ""); string[] lists = text.Split('\n'); int index = 0; while (!lists[index].Contains(fileType)) { index++; } List <string> result = new List <string>(); for (int i = index + 1; i < lists.Length; i++) { if (String.IsNullOrEmpty(lists[i])) { continue; } if (lists[i].Contains("[")) { break; } result.Add(lists[i]); } return(result.ToArray()); }
public bool GeneJava(String xmlDir, String xmlListFile, String package, String javaOutPath) { try { string[] lists = GetPropertiesList(xmlListFile, "ForJava" + package); //ClearFolder(javaOutPath); Console.WriteLine("-----> " + javaOutPath); foreach (string csName in lists) { string text = FileOpt.ReadTextFromFile(xmlDir + csName + ".xml"); Dictionary <string, List <MyClassMember> > dictionary = xParser.GeneMembersByXmlText(csName, text); foreach (var d in dictionary) { List <MyClassMember> members = d.Value; string content = GeneJavaFile(csName, members); if (FileOpt.WriteText(content, javaOutPath + csName + ".java")) { Console.WriteLine("生成Java文件成功:" + "ForJava-" + package + " " + csName); } break; } } } catch (Exception e) { Console.WriteLine(e); return(false); } return(true); }
public bool GeneCs(string xmlPath, string outPutDir) { try { Console.WriteLine("Generate Text Color Config"); TableData td = xParser.GetTableData(Path.GetFileNameWithoutExtension(xmlPath), FileOpt.ReadTextFromFile(xmlPath)); string content = GetSharpHeader(); List <ColorConfig> configList = new List <ColorConfig>(); foreach (SheetData sd in td.sheets) { foreach (RowData rd in sd.dataRows) { var config = new ColorConfig(); config.desc = GetSummary(rd); config.id = GetID(rd); config.name = GetName(rd); config.value = GetValue(rd); configList.Add(config); } } content += GenGetColor(configList); content += GenColorCode(configList); content += "\t}\n}\n"; FileOpt.WriteText(content, outPutDir + "ColorConfig.cs"); return(true); } catch (Exception e) { Console.WriteLine(e.ToString()); return(false); } }
public bool GeneJava(string serverName, string outPutDir, string xmlPath, params string[] typeExcept) { if (string.IsNullOrEmpty(outPutDir)) { Console.WriteLine("JAVA 空路径不生成!"); return(true); } try { FileOpt.ClearFolder(outPutDir); TableData td = xParser.GetTableData(Path.GetFileNameWithoutExtension(xmlPath), FileOpt.ReadTextFromFile(xmlPath)); string configmngr = serverName + "Config"; string pkgPath = GetPackagePath(outPutDir); foreach (SheetData sd in td.sheets) { if (sd.name.Contains("(") && !sd.name.ToLower().Contains("(server")) { continue; } int i = sd.name.IndexOf('('); if (i > 0) { sd.name = sd.name.Substring(0, i); } string content = GetHeader(configmngr, pkgPath, td.name, sd.name); foreach (RowData rd in sd.dataRows) { if (typeExcept.Contains(rd.cells[2].value)) { continue; } content += GetJavaRowStr(td.name, sd.name, configmngr , rd.cells[0].intValue, rd.cells[1].value , rd.cells[2].value, rd.cells[3].value , rd.cells[4].value); } content += "}\n"; FileOpt.WriteText(content, outPutDir + sd.name + ".java"); } return(true); } catch (Exception e) { Console.WriteLine(e.ToString()); return(false); } }
public bool GeneCs(string xmlPath, string outPutDir) { try { TableData td = xParser.GetTableData(Path.GetFileNameWithoutExtension(xmlPath), FileOpt.ReadTextFromFile(xmlPath)); List <string> except = new List <string>(); except.Add("LTKey.cs"); foreach (SheetData sd in td.sheets) { if (sd.name.Contains("(") && !sd.name.ToLower().Contains("(client")) { continue; } int i = sd.name.IndexOf('('); if (i > 0) { sd.name = sd.name.Substring(0, i); } string content = GetSharpHeader(sd.name); foreach (RowData rd in sd.dataRows) { content += GetSharpRowStr(td.name, rd.cells[0].intValue , rd.cells[1].value, rd.cells[2].value , rd.cells[3].value, rd.cells[4].value); } content += " }\n}\n"; except.Add(sd.name); FileOpt.WriteText(content, outPutDir + sd.name + ".cs"); } FileOpt.ClearFolder(outPutDir, "*.cs", except.ToArray()); return(true); } catch (Exception e) { Console.WriteLine(e.ToString()); return(false); } }
public bool GeneCs(String xmlDir, String xmlListFile, String csOutPath) { string[] lists = GetPropertiesList(xmlListFile, "ForCSharp"); //ClearFolder(csOutPath); foreach (string csName in lists) { string text = FileOpt.ReadTextFromFile(xmlDir + csName + ".xml"); Dictionary <string, List <MyClassMember> > dictionary = xParser.GeneMembersByXmlText(csName, text); foreach (var d in dictionary) { List <MyClassMember> members = d.Value; string content = GeneCsFile(csName, members); if (FileOpt.WriteText(content, csOutPath + csName + ".cs")) { Console.WriteLine("生成CS数据表成功:" + csName); } } } return(true); }