Example #1
0
        public void LoadCodeFile(CodeFile codeFile)
        {
            if (!ProtoFiles.TryGetValue(codeFile.Name, out var protoFile))
            {
                protoFile = new ProtoFile();
                protoFile.SetFileName(codeFile.Name);
                protoFile.SetSyntax(codeFile.Syntax);
                protoFile.SetPackage(codeFile.Package);
                protoFile.SetOption(codeFile.Option);
                ProtoFiles.Add(protoFile.Name, protoFile);
            }

            protoFile.LoadCodeFile(codeFile);
        }
Example #2
0
        public static void ProtoBuffFile(ProtoFile protoFile)
        {
            var fileInfo = new FileInfo(protoFile.FullName);

            if (!fileInfo.Exists)
            {
                return;
            }

            if (fileInfo.Directory == null)
            {
                return;
            }

            string outPutfile    = "./";
            var    outPutDirList = new List <string>();

            if (protoFile.Option.Contains("Client"))
            {
                outPutfile = fileInfo.Directory.FullName.Replace(@"\Proto\", @"\Client\");
                outPutDirList.Add(outPutfile);
            }
            outPutfile = fileInfo.Directory.FullName.Replace(@"\Proto\", @"\Server\");
            outPutDirList.Add(outPutfile);

            foreach (var outPutDir in outPutDirList)
            {
                var outPutDirectory = new DirectoryInfo(outPutDir);
                if (!outPutDirectory.Exists)
                {
                    outPutDirectory.Create();
                }

                //调用外部程序protoc.exe
                CmdProcessUtil.RunCmdProcess($@"{FolderManager.Inst.GoogleGeneratorFileDirectory}\protoc.exe", $@"-I . --csharp_out={outPutDir} {protoFile.Name}", FolderManager.Inst.CurrentDirectory);
            }
        }
Example #3
0
 public ProtoFileGenerator(ProtoFile protoFile)
 {
     _protoFile = protoFile;
 }