Ejemplo n.º 1
0
        private void generateBtn_Click(object sender, EventArgs e)
        {
            GeneratorMsgTextBox.Clear();
            outPutProtoTextBox.Clear();
            outputMsg.Clear();
            string[] aryString = (!String.IsNullOrEmpty(SourceText.Text.Trim())) ? SourceText.Lines : null;
            if (aryString == null)
            {
                return;
            }
            aryString = aryString.Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();  //去除空行
            List <String> inputLines       = new List <string>(aryString);
            List <String> outputProtoLines = Convert(inputLines);

            StaticInfo.checkoutPath();
            string pathOutput = StaticInfo.outputPath + StaticInfo.javaPackageName.Replace(".", "/") + "/" + className + ".proto";

            fileIOBusiness.CreateFloder(StaticInfo.outputPath + StaticInfo.javaPackageName.Replace(".", "/") + "/");
            fileIOBusiness.WriteFile(outputProtoLines, pathOutput);
            StaticInfo.checkoutPath2();
            fileIOBusiness.WriteFile(outputProtoLines, StaticInfo.generateorPath + className + ".proto");
            GenerateJava(pathOutput);
            outputMsg.Add("proto生成成功");
            outPutProtoTextBox.Text  = String.Join(Environment.NewLine, outputProtoLines.ToArray());
            GeneratorMsgTextBox.Text = String.Join(Environment.NewLine, outputMsg.ToArray());
        }
Ejemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            string className    = ClassNameBox1.Text;
            string businessName = BusinessNameBox1.Text;

            if (String.IsNullOrWhiteSpace(className) || String.IsNullOrWhiteSpace(businessName))
            {
                return;
            }
            FileIOBusiness fileIO = new FileIOBusiness();

            fileIO.CreateFloder(outputFinalFloder + @"\" + businessName);

            lines.Clear();
            addHead("PBDictionaryFor" + className + "List");
            lines.Add("import \"" + className + ".proto\";");
            lines.Add("");


            lines.Add("message DictionaryFor" + className + "List");
            lines.Add("{");
            lines.Add("repeated KVForDictionaryFor" + className + "List KeyValuePair = 1;");
            lines.Add("}");

            lines.Add("message KVForDictionaryFor" + className + "List");
            lines.Add("{");
            lines.Add("optional int32 Key = 1;");
            lines.Add("repeated " + className + " Value = 2;");
            lines.Add("}");

            fileIO.WriteFile(lines, outputFinalFloder + businessName + @"\" + "DictionaryFor" + className + "List.proto");
            fileIO.WriteFile(lines, outputFloder + "output1.proto");

            lines.Clear();
            addHead("PBDynamicIncreaseInfoFor" + businessName);
            lines.Add("import \"" + className + ".proto\";");
            lines.Add("import \"DictionaryForListInt.proto\";");
            lines.Add("");

            lines.Add("message KVForDicAddOrUpdateInfoFor" + businessName);
            lines.Add("{");
            lines.Add("optional int32 Key = 1;");
            lines.Add("repeated " + className + " Value = 2;");
            lines.Add("}");

            lines.Add("message DynamicIncreaseInfoFor" + businessName);
            lines.Add("{");
            lines.Add("repeated KVForDictionaryForListInt DicDeleteInfo = 1;");
            lines.Add("repeated KVForDicAddOrUpdateInfoFor" + businessName + " DicAddOrUpdateInfo = 2;");
            lines.Add("}");

            fileIO.WriteFile(lines, outputFinalFloder + businessName + @"\" + "DynamicIncreaseInfoFor" + businessName + ".proto");
            fileIO.WriteFile(lines, outputFloder + "output2.proto");
        }