Example #1
0
        public static void Main()
        {
            string protoc = "";

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                protoc = "protoc.exe";
            }
            else
            {
                protoc = "protoc";
            }
            ProcessHelper.Run(protoc, "--csharp_out=\"../Unity/Assets/Model/Module/Message/\" --proto_path=\"./\" OuterMessage.proto", waitExit: true);
            ProcessHelper.Run(protoc, "--csharp_out=\"../Unity/Assets/Hotfix/Module/Message/\" --proto_path=\"./\" HotfixMessage.proto", waitExit: true);

            // InnerMessage.proto生成cs代码
            InnerProto2CS.Proto2CS();

            msgOpcode.Clear();
            Proto2CS("ETModel", "OuterMessage.proto", clientMessagePath, "OuterOpcode", 100);

            msgOpcode.Clear();
            Proto2CS("ETHotfix", "HotfixMessage.proto", hotfixMessagePath, "HotfixOpcode", 10000);

            Console.WriteLine("proto2cs succeed!");
        }
Example #2
0
        public static void Main()
        {
            Run("protoc.exe", "--csharp_out=\"./Message/\" --proto_path=\"./\" OuterMessage.proto");
            Run("protoc.exe", "--csharp_out=\"./Message/\" --proto_path=\"./\" HotfixMessage.proto");

            // InnerMessage.proto生成cs代码
            InnerProto2CS.Proto2CS();

            msgOpcode.Clear();
            Proto2CS("ETModel", "OuterMessage.proto", clientMessagePath, "OuterOpcode", 100);

            msgOpcode.Clear();
            Proto2CS("ETHotfix", "HotfixMessage.proto", hotfixMessagePath, "HotfixOpcode", 10000);

            Console.WriteLine("proto2cs succeed!");
        }
Example #3
0
        public static void Main()
        {
            string protoc = "";

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                protoc = "protoc.exe";
            }
            else
            {
                protoc = "protoc";
            }

            // 遍历所有文件
            DirectoryInfo fdir = new DirectoryInfo(".");

            FileInfo[] file = fdir.GetFiles();
            if (file.Length != 0)            //当前目录文件或文件夹不为空
            {
                foreach (FileInfo f in file) //显示当前目录所有文件
                {
                    if (f.Extension.ToLower().Equals(".proto"))
                    {
                        string protoType      = f.Name.Substring(0, 2);
                        string opcodeFileName = f.Name.Substring(0, f.Name.Length - 6) + "Opcode";

                        switch (protoType)
                        {
                        case "OM":
                            ProcessHelper.Run(protoc, $"--csharp_out=\"{clientMessagePath}\" --proto_path=\"./\" {f.Name}", waitExit: true);
                            OuterProto2CS.Proto2CS("ET", f.Name, clientMessagePath, opcodeFileName);
                            break;

                        case "IM":
                            InnerProto2CS.Proto2CS("ET", f.Name, serverMessagePath, opcodeFileName);
                            break;

                        default:
                            throw new FileLoadException("proto文件名必须以OM或者IM开头");
                        }
                    }
                }
            }

            Console.WriteLine("proto2cs succeed!");
        }