private void button2_Click(object sender, EventArgs e) { List <String> outPutLines = new List <string>(); List <String> tmpLines = new List <string>(); List <String> importLines = new List <string>(); string className = ClassNameBox.Text; string pathOutput = outputFloder + className + "List.proto"; //初始化头部 outPutLines.Add("syntax = \"proto2\";"); outPutLines.Add("package tmp;"); outPutLines.Add(""); outPutLines.Add("option java_package = \"" + javaPakageName + "\";"); outPutLines.Add("option java_outer_classname = \"PB" + className + "List\";"); outPutLines.Add(""); outPutLines.Add("import \"" + className + ".proto\";"); outPutLines.Add("message " + className + "List"); outPutLines.Add("{"); outPutLines.Add("repeated " + className + " Element = 1;"); outPutLines.Add("}"); FileIOBusiness fileIOBusiness = new FileIOBusiness(); fileIOBusiness.WriteFile(outPutLines, pathOutput); }
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"); }
private void button1_Click(object sender, EventArgs e) { List <String> outPutLines = new List <string>(); List <String> tmpLines = new List <string>(); List <String> importLines = new List <string>(); string key = KeyBox.Text; string className = ClassNameBox.Text; string value = ValueBox.Text; string pathOutput = outputFloder + "DictionaryFor" + className + ".proto"; if (String.IsNullOrWhiteSpace(className)) { className = "" + value; ClassNameBox.Text = className; } //初始化头部 outPutLines.Add("syntax = \"proto2\";"); outPutLines.Add("package tmp;"); outPutLines.Add(""); outPutLines.Add("option java_package = \"" + javaPakageName + "\";"); outPutLines.Add("option java_outer_classname = \"PBDictionaryFor" + className + "\";"); outPutLines.Add(""); tmpLines.Add("optional " + StaticInfo.getParaNameAndImport(key, ref importLines) + " Key = 1;"); if (Regex.Matches(value, @"\s*?List\<(\w*)\>\s*?").Count == 1 && Regex.Matches(value, ">").Count == 1) { tmpLines.Add("repeated " + StaticInfo.getParaNameAndImport(Regex.Matches(value, @"\s*?List\<(\w*)\>\s*?")[0].Groups[1].Value, ref importLines) + " Value = 2;"); } else { tmpLines.Add("optional " + StaticInfo.getParaNameAndImport(value, ref importLines) + " Value = 2;"); } outPutLines.AddRange(importLines); outPutLines.Add("message DictionaryFor" + className); outPutLines.Add("{"); outPutLines.Add("repeated KVForDictionaryFor" + className + " KeyValuePair = 1;"); outPutLines.Add("}"); outPutLines.Add("message KVForDictionaryFor" + className); outPutLines.Add("{"); outPutLines.AddRange(tmpLines); outPutLines.Add("}"); FileIOBusiness fileIOBusiness = new FileIOBusiness(); fileIOBusiness.WriteFile(outPutLines, pathOutput); pathOutput = outputFloder + "output.proto"; fileIOBusiness.WriteFile(outPutLines, pathOutput); }
private void button1_Click(object sender, EventArgs e) { //获取输入 string dicDeleteInfoTxt = TextBox1.Text; string dicAddOrUpdateInfoTxt = TextBox2.Text; string className = TextBox3.Text; outPutLines.Clear(); importLines.Clear(); tmpLines.Clear(); //生成dicAddOrUpdateInfo的dictionary generateDicAddOrUpdateInfo(dicAddOrUpdateInfoTxt, className); tmpLines.Clear(); //生成DynamicIncreaseInfo generateDynamicIncreaseInfo(dicAddOrUpdateInfoTxt, dicDeleteInfoTxt, className); List <String> finalLines = new List <string>(); //初始化头部 finalLines.Add("syntax = \"proto2\";"); finalLines.Add("package tmp;"); finalLines.Add(""); finalLines.Add("option java_package = \"com.ctrip.hotel.search.internalentity.pb\";"); finalLines.Add("option java_outer_classname = \"PBDynamicIncreaseInfoFor" + className + "\";"); finalLines.Add(""); finalLines.AddRange(importLines); finalLines.AddRange(outPutLines); string pathOutput = outputFloder + "DynamicIncreaseInfoFor" + className + ".proto"; FileIOBusiness fileIOBusiness = new FileIOBusiness(); fileIOBusiness.WriteFile(finalLines, pathOutput); pathOutput = outputFloder + "output.proto"; fileIOBusiness.WriteFile(finalLines, pathOutput); }