private static void ProductClass_Message(List <Array> listArr, List <string> listStr, string IclassName, string gate) { var classNameArr = listArr[0]; var className = classNameArr.GetValue(classNameArr.Length - 1); string gateClassName = ""; string result = ""; string gateFile = ""; if (gate.Contains('.')) { var gateArr = gate.Split('.'); //className = /*IclassName + gateArr[1] + "_" + */className; gateClassName = IclassName + gateArr[1]; gateFile = "D:/TestClass/" + gateClassName + ".cs"; if (!File.Exists(gateFile)) { MyClass gateClass = new MyClass(gateClassName); gateClass.AddNameSpace("System"); result = gateClass.ToString(); } else { result = File.ReadAllText(gateFile).ToString(); gateFile = "D:/TestClass/" + gateClassName + ".cs"; } } else { //className = IclassName + className; gateClassName = gate; gateFile = "D:/TestClass/" + IclassName + gateClassName + ".cs"; } MyClass c = new MyClass(className.ToString()); var subClassName = ""; for (int i = 1; i < listArr.Count; i++) { var arr = listArr[i]; subClassName = arr.GetValue(0).ToString(); MyClass subClass = new MyClass(subClassName); for (int n = 1; n < arr.Length; n++) { var f = new MyField(); //if(n == 1) //{ // field = string.Format("public {0};", arr.GetValue(n)); //} //else //{ // field = string.Format("public {0};", arr.GetValue(n)); //} string field = string.Format("public {0};", arr.GetValue(n)); f.SetContent(field); subClass.AddField(f); } c.AddClass(subClass); } //添加field if (listStr.Count > 1) { for (int i = 0; i < listStr.Count; i++) { //先判断类型 var f = new MyField(); string field = ""; var arrField = listStr[i].Split(' '); if (arrField[0] == subClassName) { var str = listStr[i].Insert(listStr[i].LastIndexOf(' '), "[]"); field = string.Format("public {0};", str); } else { field = string.Format("public {0};", listStr[i]); } //if (i == 0) //{ // field = string.Format("public {0};", listStr[i]); //} //else //{ // field = string.Format("public {0};", listStr[i]); //} f.SetContent(field); c.AddField(f); } } var code = c.ToString(); if (gate.Contains('.')) { result = result.Insert(result.LastIndexOf('}'), code); } else { result = code; } var files = path + "/RouteClass/Response_" + c.Name + ".cs"; if (File.Exists(files)) { File.Delete(files); } File.WriteAllText(gateFile, result); //AssetDatabase.Refresh(); //ProductMethodClass_All(c, gate, listStr, IclassName); ProductMethodClass_Now(className.ToString(), gate, listStr, IclassName); }