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()); }
private void generateIncProtoBtn_Click(object sender, EventArgs e) { string businessName = BusinessNameTextBox.Text; string tIncUpdateName = TIncUpdateTextBox.Text; string tIncDeleteName = TIncDeleteTextBox.Text; GeneratorMsgTextBox.Clear(); outPutProtoTextBox.Clear(); outputMsg.Clear(); if (String.IsNullOrWhiteSpace(businessName)) { outputMsg.Add("BusinessName输入为空,无法生成全量proto"); GeneratorMsgTextBox.Text = String.Join(Environment.NewLine, outputMsg.ToArray()); return; } else if (String.IsNullOrWhiteSpace(tIncDeleteName)) { outputMsg.Add("TIncDelete输入为空,无法生成全量proto"); GeneratorMsgTextBox.Text = String.Join(Environment.NewLine, outputMsg.ToArray()); return; } else if (String.IsNullOrWhiteSpace(tIncUpdateName)) { outputMsg.Add("tTIncUpdate输入为空,无法生成全量proto"); GeneratorMsgTextBox.Text = String.Join(Environment.NewLine, outputMsg.ToArray()); return; } List <String> resLines = GenerateDynamicInfo(businessName, tIncUpdateName, tIncDeleteName); StaticInfo.checkoutPath(); string pathOutput = StaticInfo.outputPath + StaticInfo.javaPackageName.Replace(".", "/") + "/" + className + ".proto"; fileIOBusiness.CreateFloder(StaticInfo.outputPath + StaticInfo.javaPackageName.Replace(".", "/") + "/"); fileIOBusiness.WriteFile(resLines, pathOutput); GenerateJava(pathOutput); outputMsg.Add("proto生成结束"); outPutProtoTextBox.Text = String.Join(Environment.NewLine, resLines.ToArray()); GeneratorMsgTextBox.Text = String.Join(Environment.NewLine, outputMsg.ToArray()); }
private void generateAllProtoBtn_Click(object sender, EventArgs e) { string entityName = TValueTextBox.Text; GeneratorMsgTextBox.Clear(); outPutProtoTextBox.Clear(); outputMsg.Clear(); if (String.IsNullOrWhiteSpace(entityName)) { outputMsg.Add("TValue输入为空,无法生成全量proto"); GeneratorMsgTextBox.Text = String.Join(Environment.NewLine, outputMsg.ToArray()); return; } // 多层 List / Dictionary 嵌套 判定 int hitMulti = Regex.Matches(entityName, @"List\<Dictionary\<").Count + Regex.Matches(entityName, @"List\<List\<").Count + Regex.Matches(entityName, @"Dictionary\<Dictionary\<").Count + Regex.Matches(entityName, @"Dictionary\<List\<").Count + Regex.Matches(entityName, @"\>\>+").Count; if (hitMulti > 0) { outputMsg.Add("TValue:" + entityName + ":为多层 List / Dictionary 嵌套,请手动生成"); GeneratorMsgTextBox.Text = String.Join(Environment.NewLine, outputMsg.ToArray()); return; } List <String> resLines = GenerateTValueDic(entityName); StaticInfo.checkoutPath(); string pathOutput = StaticInfo.outputPath + StaticInfo.javaPackageName.Replace(".", "/") + "/" + className + ".proto"; fileIOBusiness.CreateFloder(StaticInfo.outputPath + StaticInfo.javaPackageName.Replace(".", "/") + "/"); fileIOBusiness.WriteFile(resLines, pathOutput); GenerateJava(pathOutput); outputMsg.Add("proto生成结束"); outPutProtoTextBox.Text = String.Join(Environment.NewLine, resLines.ToArray()); GeneratorMsgTextBox.Text = String.Join(Environment.NewLine, outputMsg.ToArray()); }