コード例 #1
0
        public static void RunDoxygen(IEnumerable<string> inputs, string outputDir, DataReceivedEventHandler stdoutDataReveiver = null)
        {
            var outputDirInfo = new DirectoryInfo(outputDir);

            if (!outputDirInfo.Exists)
            {
                outputDirInfo.Create();
            }

            var configPath = Path.Combine(outputDir, "doxygen.config");

            var template =
                new DoxygenConfig(
                    string.Join(" \\" + Environment.NewLine, inputs.Select(input => "\"" + input + "\"")),
                    "\"" + outputDir + "\"");

            File.WriteAllText(configPath, template.TransformText());

            var doxygenProcess = new Process
            {
                StartInfo =
                {
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    FileName = DoxygenExec.FullName,
                    Arguments = configPath,
                    CreateNoWindow = true
                },

                EnableRaisingEvents = true
            };

            // The progress estimation is not accurate. It divides the process into 3 equal
            // parts: first parsing input files, second building group list and third finished.
            // Each of these parts may last variable amount of time. It can be improved, but
            // it will require some research and implementation. The += 0.0000333 on every
            // stdout newline gives the impression of progress. If it is not enough, please
            // TTP it.
            double lastProgress = 0.0;

            doxygenProcess.OutputDataReceived += (sender, args) =>
                {
                    if (args.Data == null)
                    {
                        ProgressChanged(1.0);
                        return;
                    }

                    switch (args.Data)
                    {
                        case "Building group list...":
                            lastProgress = 1.0 / 3.0;
                            break;
                        case "Generating XML output...":
                            lastProgress = 2.0 / 3.0;
                            break;
                        case "finished...":
                            // when it's finished then return
                            ProgressChanged(1.0);
                            return;
                        default:
                            lastProgress += 0.0000333;
                            break;
                    }

                    if (lastProgress > 0.0 && lastProgress < 1.0)
                    {
                        ProgressChanged(lastProgress);
                    }

                    if (lastProgress >= 1.0)
                    {
                        // almost finished
                        ProgressChanged(0.9999999);
                    }
                };

            if (stdoutDataReveiver != null)
            {
                doxygenProcess.OutputDataReceived += stdoutDataReveiver;
            }

            if (doxygenProcess.Start())
            {
                doxygenProcess.BeginOutputReadLine();
                doxygenProcess.WaitForExit();
            }
        }
コード例 #2
0
        public static void RunDoxygen(IEnumerable <string> inputs, string outputDir, DataReceivedEventHandler stdoutDataReveiver = null)
        {
            var outputDirInfo = new DirectoryInfo(outputDir);

            if (!outputDirInfo.Exists)
            {
                outputDirInfo.Create();
            }

            var configPath = Path.Combine(outputDir, "doxygen.config");

            var template =
                new DoxygenConfig(
                    string.Join(" \\" + Environment.NewLine, inputs.Select(input => "\"" + input + "\"")),
                    "\"" + outputDir + "\"");

            File.WriteAllText(configPath, template.TransformText());

            var doxygenProcess = new Process
            {
                StartInfo =
                {
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    FileName       = DoxygenExec.FullName,
                    Arguments      = configPath,
                    CreateNoWindow = true
                },

                EnableRaisingEvents = true
            };

            // The progress estimation is not accurate. It divides the process into 3 equal
            // parts: first parsing input files, second building group list and third finished.
            // Each of these parts may last variable amount of time. It can be improved, but
            // it will require some research and implementation. The += 0.0000333 on every
            // stdout newline gives the impression of progress. If it is not enough, please
            // TTP it.
            double lastProgress = 0.0;

            doxygenProcess.OutputDataReceived += (sender, args) =>
            {
                if (args.Data == null)
                {
                    ProgressChanged(1.0);
                    return;
                }

                switch (args.Data)
                {
                case "Building group list...":
                    lastProgress = 1.0 / 3.0;
                    break;

                case "Generating XML output...":
                    lastProgress = 2.0 / 3.0;
                    break;

                case "finished...":
                    // when it's finished then return
                    ProgressChanged(1.0);
                    return;

                default:
                    lastProgress += 0.0000333;
                    break;
                }

                if (lastProgress > 0.0 && lastProgress < 1.0)
                {
                    ProgressChanged(lastProgress);
                }

                if (lastProgress >= 1.0)
                {
                    // almost finished
                    ProgressChanged(0.9999999);
                }
            };

            if (stdoutDataReveiver != null)
            {
                doxygenProcess.OutputDataReceived += stdoutDataReveiver;
            }

            if (doxygenProcess.Start())
            {
                doxygenProcess.BeginOutputReadLine();
                doxygenProcess.WaitForExit();
            }
        }