/// <summary> 呼叫highlight.exe 產生高亮後的html </summary>
        /// <returns>回傳 Html 所在的路徑</returns>
        public string GenerateHighLightCode(HighLightParameter parameter)
        {
            var result = ConfigurationManager.GetSection("HighLightSection");
            _section = result as HighLightSection;

            InitParameter(parameter);

            string tempPath = Path.GetTempPath();
            string inputFileName = Path.Combine(tempPath, FileName);
            string outputFileName = Path.Combine(tempPath, FileName) + ".html";

            //System.Diagnostics.Debug.WriteLine(inputFileName);
            //System.Diagnostics.Debug.WriteLine(Content);
            //System.Diagnostics.Debug.WriteLine(_section);
            //System.Diagnostics.Debug.WriteLine(_section.FolderName);
            //System.Diagnostics.Debug.WriteLine(ProcessHelper.GetAssemblyLocationDirectory);
            File.WriteAllText(inputFileName, Content, Encoding.UTF8);
            
            var workingDirectory = Path.Combine(ProcessHelper.GetAssemblyLocationDirectory, _section.FolderName);

            ProcessHelper helper = new ProcessHelper(workingDirectory, _section.ProcessName);
            helper.Arguments = GenerateArguments(inputFileName, outputFileName);
            helper.IsWaitForInputIdle = false;
            helper.WindowStyle = ProcessWindowStyle.Hidden;

            helper.ProcessStart();

            if (!File.Exists(outputFileName))
                throw new FileNotFoundException("找不到outputFile");

            File.Delete(inputFileName);
            return outputFileName;
        }
Ejemplo n.º 2
0
        /// <summary> 呼叫highlight.exe 產生高亮後的html </summary>
        /// <returns>回傳 Html 所在的路徑</returns>
        public string GenerateHighLightCode(HighLightParameter parameter)
        {
            var result = ConfigurationManager.GetSection("HighLightSection");

            _section = result as HighLightSection;

            InitParameter(parameter);

            string tempPath       = Path.GetTempPath();
            string inputFileName  = Path.Combine(tempPath, FileName);
            string outputFileName = Path.Combine(tempPath, FileName) + ".html";

            //System.Diagnostics.Debug.WriteLine(inputFileName);
            //System.Diagnostics.Debug.WriteLine(Content);
            //System.Diagnostics.Debug.WriteLine(_section);
            //System.Diagnostics.Debug.WriteLine(_section.FolderName);
            //System.Diagnostics.Debug.WriteLine(ProcessHelper.GetAssemblyLocationDirectory);
            File.WriteAllText(inputFileName, Content, Encoding.UTF8);

            var workingDirectory = Path.Combine(ProcessHelper.GetAssemblyLocationDirectory, _section.FolderName);

            ProcessHelper helper = new ProcessHelper(workingDirectory, _section.ProcessName);

            helper.Arguments          = GenerateArguments(inputFileName, outputFileName);
            helper.IsWaitForInputIdle = false;
            helper.WindowStyle        = ProcessWindowStyle.Hidden;

            helper.ProcessStart();

            if (!File.Exists(outputFileName))
            {
                throw new FileNotFoundException("找不到outputFile");
            }

            File.Delete(inputFileName);
            return(outputFileName);
        }