Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
        }