public ProtocolBuffersAssemblyGenerator(ProtoFileGenerator protoFileGenerator, Func <PropertyInfo, bool> propertyFilter = null) { CompilerPath = ".\\protoc.exe"; ProtoFileGenerator = protoFileGenerator; CsFileDirectory = ".\\Generated_Protobuf_Cs"; if (propertyFilter != null) { PropertyFilter = propertyFilter; } Types = new HashSet <Type>(); }
public DirectoryInfo GenerateCsFiles(EventHandler onComplete = null) { string protoFilePath = ProtoFileGenerator.GenerateProtoFile(Types); DirectoryInfo dir = new DirectoryInfo(CsFileDirectory); if (Directory.Exists(dir.FullName)) { Directory.Move(dir.FullName, dir.FullName.GetNextDirectoryName()); } dir.Create(); FileInfo compiler = new FileInfo(CompilerPath); string command = $"{compiler.FullName} -I={compiler.Directory.FullName} --csharp_out={dir.FullName} {protoFilePath}"; ProcessOutput output = null; AutoResetEvent wait = new AutoResetEvent(false); output = command.Run((o, a) => { onComplete?.Invoke(o, a); wait.Set(); }); wait.WaitOne(); return(dir); }