Ejemplo n.º 1
0
        public DecodeResult Decode(DecodeTask task)
        {
            var tempDirectory = CreateTempDirectory();
            var arguments     = CreateArgumentsForTask(task, tempDirectory);

            try
            {
                using (var protoCProcess = new Process
                {
                    StartInfo = GetProcessStartInfo(tempDirectory, arguments)
                })
                {
                    protoCProcess.Start();

                    var standardInput = protoCProcess.StandardInput;
                    WriteEncodedMessageToStandardInput(standardInput, task.MessageBinary);

                    var output = protoCProcess.StandardOutput.ReadToEnd();
                    var error  = protoCProcess.StandardError.ReadToEnd();

                    return(new DecodeResult()
                    {
                        DecodedMessage = output,
                        CompilerOutput = error
                    });
                }
            }
            finally
            {
                Directory.Delete(tempDirectory, true);
            }
        }
Ejemplo n.º 2
0
        private string CreateArgumentsForTask(DecodeTask task, string tempDirectory)
        {
            var definitionfilePath = WriteDefinitionToFile(tempDirectory, task);

            var arguments = string.Format("--decode {0} --error_format=msvs  {1}", task.RootMessageName, definitionfilePath);

            return(arguments);
        }
Ejemplo n.º 3
0
        private void DoDecodeMessage()
        {
            var task = new DecodeTask()
            {
                MessageDefinition = MessageDefinition,
                MessageBinary     = MessageBinary,
                RootMessageName   = RootMessageName,
            };

            var result = _compiler.Decode(task);

            MessageText = result.DecodedMessage;
            Errors      = result.CompilerOutput;
        }