Esempio n. 1
0
        /// <summary>
        /// Gets the markdown content of the aggregated results and saves it to disk
        /// </summary>
        private void GenerateProfilerReport()
        {
            try
            {
                var profilerFile = FileToLog;
                Console.WriteLine(ResourceUtilities.FormatResourceString("WritingProfilerReport", profilerFile));

                var content = ProfilerResultPrettyPrinter.GetMarkdownContent(GetAggregatedResult());
                File.WriteAllText(profilerFile, content);

                Console.WriteLine(ResourceUtilities.GetResourceString("WritingProfilerReportDone"));
            }
            catch (DirectoryNotFoundException ex)
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("ErrorWritingProfilerReport", ex.Message));
            }
            catch (IOException ex)
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("ErrorWritingProfilerReport", ex.Message));
            }
            catch (UnauthorizedAccessException ex)
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("ErrorWritingProfilerReport", ex.Message));
            }
            catch (SecurityException ex)
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("ErrorWritingProfilerReport", ex.Message));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Pretty prints the aggregated results and saves it to disk
        /// </summary>
        /// <remarks>
        /// If the extension of the file to log is 'md', markdown content is generated. Otherwise, it falls
        /// back to a tab separated format
        /// </remarks>
        private void GenerateProfilerReport()
        {
            try
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("WritingProfilerReport", FileToLog));

                // If the extension of the file is 'md', markdown content is produced. For any other case,
                // a tab separated format is generated
                var content = System.IO.Path.GetExtension(FileToLog) == ".md"
                    ? ProfilerResultPrettyPrinter.GetMarkdownContent(GetAggregatedResult())
                    : ProfilerResultPrettyPrinter.GetTsvContent(GetAggregatedResult());

                File.WriteAllText(FileToLog, content);

                Console.WriteLine(ResourceUtilities.GetResourceString("WritingProfilerReportDone"));
            }
            catch (DirectoryNotFoundException ex)
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("ErrorWritingProfilerReport", ex.Message));
            }
            catch (IOException ex)
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("ErrorWritingProfilerReport", ex.Message));
            }
            catch (UnauthorizedAccessException ex)
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("ErrorWritingProfilerReport", ex.Message));
            }
            catch (SecurityException ex)
            {
                Console.WriteLine(ResourceUtilities.FormatResourceString("ErrorWritingProfilerReport", ex.Message));
            }
        }