Separate out console write as well

This commit is contained in:
Matt Nadareski
2024-10-30 13:41:45 -04:00
parent 4d5b0486a2
commit 876f7223b0
2 changed files with 19 additions and 6 deletions

View File

@@ -40,8 +40,8 @@ namespace SabreTools.Reports
{ {
return statReportFormat switch return statReportFormat switch
{ {
StatReportFormat.None => new Textfile(statsList, true), StatReportFormat.None => new ConsoleOutput(statsList),
StatReportFormat.Textfile => new Textfile(statsList, false), StatReportFormat.Textfile => new Textfile(statsList),
StatReportFormat.CSV => new CommaSeparatedValue(statsList), StatReportFormat.CSV => new CommaSeparatedValue(statsList),
StatReportFormat.HTML => new Html(statsList), StatReportFormat.HTML => new Html(statsList),
StatReportFormat.SSV => new SemicolonSeparatedValue(statsList), StatReportFormat.SSV => new SemicolonSeparatedValue(statsList),

View File

@@ -13,17 +13,15 @@ namespace SabreTools.Reports.Formats
/// </summary> /// </summary>
internal class Textfile : BaseReport internal class Textfile : BaseReport
{ {
private readonly bool _writeToConsole; protected bool _writeToConsole = false;
/// <summary> /// <summary>
/// Create a new report from the filename /// Create a new report from the filename
/// </summary> /// </summary>
/// <param name="statsList">List of statistics objects to set</param> /// <param name="statsList">List of statistics objects to set</param>
/// <param name="writeToConsole">True to write to consoke output, false otherwise</param> public Textfile(List<DatStatistics> statsList)
public Textfile(List<DatStatistics> statsList, bool writeToConsole)
: base(statsList) : base(statsList)
{ {
_writeToConsole = writeToConsole;
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -127,4 +125,19 @@ namespace SabreTools.Reports.Formats
sw.Flush(); sw.Flush();
} }
} }
/// <summary>
/// Console report format
/// </summary>
internal sealed class ConsoleOutput : Textfile
{
/// <summary>
/// Create a new report from the filename
/// </summary>
/// <param name="statsList">List of statistics objects to set</param>
public ConsoleOutput(List<DatStatistics> statsList) : base(statsList)
{
_writeToConsole = true;
}
}
} }