private static void Convert(ConversionSource conversionSource) { var processStartInfo = GetProcessStartInfo(); var process = Process.Start(processStartInfo); process.Convert(conversionSource); }
private static string SerializeToJson(ConversionSource conversionSource) { using (var stream = new MemoryStream()) { new DataContractJsonSerializer(typeof(ConversionSource)).WriteObject(stream, conversionSource); stream.Position = 0; return(new StreamReader(stream).ReadToEnd()); } }
private static ConversionSource ToConversionSource(string html, IDictionary <string, string> globalSettings, IDictionary <string, string> objectSettings) { var conversionSource = new ConversionSource { Html = html, GlobalSettings = globalSettings, ObjectSettings = objectSettings }; return(conversionSource); }
private static string SerializeToBase64EncodedString(ConversionSource conversionSource) { var result = SerializeToJson(conversionSource); return(System.Convert.ToBase64String(Encoding.UTF8.GetBytes(result))); }
private static void WriteToStandardInput(this Process process, ConversionSource conversionSource) { process.StandardInput.Write(SerializeToBase64EncodedString(conversionSource)); process.StandardInput.Close(); }
private static void Convert(this Process process, ConversionSource conversionSource) { process.WriteToStandardInput(conversionSource); process.WaitForExit(); RaiseExceptionIfErrorOccured(process); }