public static void ExportApi(string inPath, string outPath, string name) { string proBufStr = File.ReadAllText(inPath, Encoding.UTF8); name += "_pb"; EmmyProtoBufExport export = new EmmyProtoBufExport(proBufStr, name); name += ".lua"; var path = Path.Combine(outPath, name); try { if (File.Exists(path)) { File.Delete(path); } } catch (System.Exception ex) { } FileStream fs = new FileStream(path, FileMode.Create); var utf8WithoutBom = new System.Text.UTF8Encoding(false); StreamWriter sw = new StreamWriter(fs, utf8WithoutBom); sw.Write(export.ToString()); //清空缓冲区 sw.Flush(); sw.Close(); fs.Close(); }
public ProBufAPI(string messageStr, string parent) { string[] fieldArray; EmmyProtoBufExport.GetClassInfo("message", messageStr, parent, out packageName, out className, out fieldArray); for (int i = 0; i < fieldArray.Length - 1; i++) { string lineStr = (fieldArray[i].Split('=') [0]).Trim(); if (string.IsNullOrEmpty(lineStr)) { continue; } ProBufAPIFiled pf = new ProBufAPIFiled(lineStr, packageName); fieldList.Add(pf); } }
public ProBufAPIEnum(string messageStr, string parent) { string[] fieldArray; EmmyProtoBufExport.GetClassInfo("enum", messageStr, parent, out packageName, out className, out fieldArray); for (int i = 0; i < fieldArray.Length - 1; i++) { var lineStr = fieldArray[i].Split('='); var key = lineStr[0].Trim(); try { var number = System.Convert.ToInt32(lineStr[1].Trim()); fieldList[key] = number; } catch (System.Exception ex) { Debug.Log(ex.ToString()); } } }
public static void BuildiPhoneResource() { EmmyProtoBufExport.ExportApi(AppConst.FrameworkRoot + "/Lua/test/protobuf"); }