Example #1
0
        public string Execute(object model)
        {
            var process = new Process
            {
                StartInfo = new ProcessStartInfo("php.exe", "main.php")
                {
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false
                }
            };

            process.Start();

            var templateDescriptor = new PhpTemplateRenderDescription
            {
                TemplateBody = _templateBody,
                Model        = model
            };

            var serializer = new JsonSerializer();

            using (var streamWriter = new JsonTextWriter(process.StandardInput))
            {
                serializer.Serialize(streamWriter, templateDescriptor);
            }

            process.WaitForExit();
            var result = process.StandardOutput.ReadToEnd();
            var error  = process.StandardError.ReadToEnd();

            return(result);
        }
        public string Execute(object model)
        {
            var process = new Process
                              {
                                  StartInfo = new ProcessStartInfo("php.exe", "main.php")
                                                  {
                                                      RedirectStandardInput = true,
                                                      RedirectStandardOutput = true,
                                                      RedirectStandardError = true,
                                                      UseShellExecute = false
                                                  }

                              };

            process.Start();

            var templateDescriptor = new PhpTemplateRenderDescription
                                         {
                                             TemplateBody = _templateBody,
                                             Model = model
                                         };

            var serializer = new JsonSerializer();
            using (var streamWriter = new JsonTextWriter(process.StandardInput))
            {
                serializer.Serialize(streamWriter, templateDescriptor);
            }

            process.WaitForExit();
            var result = process.StandardOutput.ReadToEnd();
            var error = process.StandardError.ReadToEnd();
            return result;
        }