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); } }