private static ProcessDetails GetProcessDetails(DiagnosticReportType type)
        {
            if (!IsReportEnabled(type, DiagnosticReportType.Process))
            {
                return(null);
            }

            using (var p = Process.GetCurrentProcess())
            {
                var pVerInfo = p.MainModule.FileVersionInfo;
                return(new ProcessDetails
                {
                    PID = p.Id,
                    Name = p.ProcessName,
                    Started = p.StartTime,
                    LoadedIn = ApplicationHelper.GetProcessStartupDuration(),
                    IsInteractive = Environment.UserInteractive,
                    IsOptimized = IsOptimized(),
                    Is64Bit = Environment.Is64BitProcess,
                    IsLargeAddressAware = ApplicationHelper.IsProcessLargeAddressAware(),
                    WorkingSetInMegaBytes = UnitConverter.BytesToMegaBytes(Environment.WorkingSet),
                    FileVersion = pVerInfo.FileVersion,
                    ProductVersion = pVerInfo.ProductVersion,
                    Language = pVerInfo.Language,
                    Copyright = pVerInfo.LegalCopyright,
                    OriginalFileName = pVerInfo.OriginalFilename,
                    FileName = pVerInfo.FileName,
                    ModuleName = p.MainModule.ModuleName,
                    ModuleFileName = p.MainModule.FileName,
                    ProductName = pVerInfo.ProductName,
                    CommandLine = Environment.GetCommandLineArgs()
                });

                string IsOptimized()
                {
                    var executingAssembly = Assembly.GetEntryAssembly();

                    return(executingAssembly == null
                        ? "N/A - Assembly was called from Unmanaged code."
                        : executingAssembly.IsOptimized().ToString());
                }
            }
        }
        private static void AddProcess(StringBuilder builder)
        {
            var maxHeaderLength = ProcessHeaders.Max(h => h.Length);
            var formatter       = "{0,-" + (maxHeaderLength + 1) + "}";

            var sectionIndex = builder.Length;

            using (var p = Process.GetCurrentProcess())
            {
                var pVerInfo = p.MainModule.FileVersionInfo;
                Format(ProcessHeaders[0], p.Id);
                Format(ProcessHeaders[1], p.ProcessName);
                Format(ProcessHeaders[2], p.StartTime.ToString("dd-MM-yyyy HH:mm:ss.fff"));
                Format(ProcessHeaders[3], ApplicationHelper.GetProcessStartupDuration());
                Format(ProcessHeaders[17], Environment.UserInteractive);
                Format(ProcessHeaders[4], IsOptimized());
                Format(ProcessHeaders[5], Environment.Is64BitProcess);
                Format(ProcessHeaders[6], ApplicationHelper.IsProcessLargeAddressAware());
                Format(ProcessHeaders[16], UnitConverter.BytesToMegaBytes(Environment.WorkingSet).ToString("N0") + "MB");
                Format(ProcessHeaders[12], pVerInfo.FileVersion);
                Format(ProcessHeaders[13], pVerInfo.ProductVersion);
                Format(ProcessHeaders[14], pVerInfo.Language);
                Format(ProcessHeaders[15], pVerInfo.LegalCopyright);
                Format(ProcessHeaders[10], pVerInfo.OriginalFilename);
                Format(ProcessHeaders[11], pVerInfo.FileName);
                Format(ProcessHeaders[7], p.MainModule.ModuleName);
                Format(ProcessHeaders[8], p.MainModule.FileName);
                Format(ProcessHeaders[9], pVerInfo.ProductName);

                var cmdArgs = Environment.GetCommandLineArgs();
                Format(ProcessHeaders[18], cmdArgs[0]);

                for (var i = 1; i < cmdArgs.Length; i++)
                {
                    builder
                    .Append(LinePrefix)
                    .Append(Space).Append(Space)
                    .AppendFormat(formatter, string.Empty)
                    .Append(Space).Append(Space)
                    .AppendLine(cmdArgs[i]);
                }

                var maxLineLength = GetMaximumLineLength(builder, sectionIndex);
                builder.Insert(sectionIndex, GetSeperator("Process", maxLineLength));

                void Format(string key, object value)
                {
                    builder
                    .Append(LinePrefix)
                    .Append(Dot)
                    .Append(Space)
                    .AppendFormat(formatter, key)
                    .Append(Colon)
                    .Append(Space)
                    .AppendLine(value.ToString());
                }

                string IsOptimized()
                {
                    var executingAssembly = Assembly.GetEntryAssembly();

                    return(executingAssembly == null
                        ? "N/A - Assembly was called from Unmanaged code."
                        : executingAssembly.IsOptimized().ToString());
                }
            }
        }