diff --git a/SabreTools.DatTools/Parser.cs b/SabreTools.DatTools/Parser.cs index ea9550f6..81207d17 100644 --- a/SabreTools.DatTools/Parser.cs +++ b/SabreTools.DatTools/Parser.cs @@ -12,6 +12,7 @@ using SabreTools.DatItems; using SabreTools.IO; using SabreTools.IO.Extensions; using SabreTools.IO.Logging; +using SabreTools.Reports; namespace SabreTools.DatTools { @@ -29,6 +30,8 @@ namespace SabreTools.DatTools #endregion + #region DatFile + /// /// Create a generic DatFile to be used /// @@ -508,5 +511,31 @@ namespace SabreTools.DatTools return line ?? string.Empty; } + + #endregion + + #region BaseReport + + /// + /// Create a specific type of BaseReport to be used based on a format and user inputs + /// + /// Format of the Statistics Report to be created + /// List of statistics objects to set + /// BaseReport of the specific internal type that corresponds to the inputs + public static BaseReport? Create(StatReportFormat statReportFormat, List statsList) + { + return statReportFormat switch + { + StatReportFormat.None => new Reports.Formats.ConsoleOutput(statsList), + StatReportFormat.Textfile => new Reports.Formats.Textfile(statsList), + StatReportFormat.CSV => new Reports.Formats.CommaSeparatedValue(statsList), + StatReportFormat.HTML => new Reports.Formats.Html(statsList), + StatReportFormat.SSV => new Reports.Formats.SemicolonSeparatedValue(statsList), + StatReportFormat.TSV => new Reports.Formats.TabSeparatedValue(statsList), + _ => null, + }; + } + + #endregion } } \ No newline at end of file diff --git a/SabreTools.DatTools/Statistics.cs b/SabreTools.DatTools/Statistics.cs index 01ee447d..b636954d 100644 --- a/SabreTools.DatTools/Statistics.cs +++ b/SabreTools.DatTools/Statistics.cs @@ -172,7 +172,7 @@ namespace SabreTools.DatTools string outfile = outfiles[reportFormat]; try { - BaseReport.Create(reportFormat, stats)?.WriteToFile(outfile, baddumpCol, nodumpCol, throwOnError); + Parser.Create(reportFormat, stats)?.WriteToFile(outfile, baddumpCol, nodumpCol, throwOnError); } catch (Exception ex) when (!throwOnError) { diff --git a/SabreTools.DatTools/Writer.cs b/SabreTools.DatTools/Writer.cs index 7967bdd9..cad387b6 100644 --- a/SabreTools.DatTools/Writer.cs +++ b/SabreTools.DatTools/Writer.cs @@ -219,7 +219,7 @@ namespace SabreTools.DatTools [ datFile.DatStatistics, ]; - var consoleOutput = BaseReport.Create(StatReportFormat.None, statsList); + var consoleOutput = Parser.Create(StatReportFormat.None, statsList); consoleOutput!.WriteToFile(null, true, true); } diff --git a/SabreTools.Reports/BaseReport.cs b/SabreTools.Reports/BaseReport.cs index a8ee4b88..ab2ff04c 100644 --- a/SabreTools.Reports/BaseReport.cs +++ b/SabreTools.Reports/BaseReport.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using SabreTools.DatFiles; using SabreTools.IO.Logging; -using SabreTools.Reports.Formats; namespace SabreTools.Reports { @@ -30,26 +29,6 @@ namespace SabreTools.Reports Statistics = statsList; } - /// - /// Create a specific type of BaseReport to be used based on a format and user inputs - /// - /// Format of the Statistics Report to be created - /// List of statistics objects to set - /// BaseReport of the specific internal type that corresponds to the inputs - public static BaseReport? Create(StatReportFormat statReportFormat, List statsList) - { - return statReportFormat switch - { - StatReportFormat.None => new ConsoleOutput(statsList), - StatReportFormat.Textfile => new Textfile(statsList), - StatReportFormat.CSV => new CommaSeparatedValue(statsList), - StatReportFormat.HTML => new Html(statsList), - StatReportFormat.SSV => new SemicolonSeparatedValue(statsList), - StatReportFormat.TSV => new TabSeparatedValue(statsList), - _ => null, - }; - } - /// /// Create and open an output file for writing direct from a set of statistics /// diff --git a/SabreTools.Reports/Formats/Html.cs b/SabreTools.Reports/Formats/Html.cs index 379d564d..82e89472 100644 --- a/SabreTools.Reports/Formats/Html.cs +++ b/SabreTools.Reports/Formats/Html.cs @@ -17,7 +17,7 @@ namespace SabreTools.Reports.Formats /// HTML report format /// /// TODO: Make output standard width, without making the entire thing a table - internal class Html : BaseReport + public class Html : BaseReport { /// /// Create a new report from the filename diff --git a/SabreTools.Reports/Formats/SeparatedValue.cs b/SabreTools.Reports/Formats/SeparatedValue.cs index 53fab06c..9a3a0230 100644 --- a/SabreTools.Reports/Formats/SeparatedValue.cs +++ b/SabreTools.Reports/Formats/SeparatedValue.cs @@ -13,7 +13,7 @@ namespace SabreTools.Reports.Formats /// /// Separated-Value report format /// - internal abstract class SeparatedValue : BaseReport + public abstract class SeparatedValue : BaseReport { // Private instance variables specific to Hashfile DATs protected char _delim; @@ -161,7 +161,7 @@ namespace SabreTools.Reports.Formats /// /// Represents a comma-separated value file /// - internal sealed class CommaSeparatedValue : SeparatedValue + public sealed class CommaSeparatedValue : SeparatedValue { /// /// Create a new report from the filename @@ -176,7 +176,7 @@ namespace SabreTools.Reports.Formats /// /// Represents a semicolon-separated value file /// - internal sealed class SemicolonSeparatedValue : SeparatedValue + public sealed class SemicolonSeparatedValue : SeparatedValue { /// /// Create a new report from the filename @@ -191,7 +191,7 @@ namespace SabreTools.Reports.Formats /// /// Represents a tab-separated value file /// - internal sealed class TabSeparatedValue : SeparatedValue + public sealed class TabSeparatedValue : SeparatedValue { /// /// Create a new report from the filename diff --git a/SabreTools.Reports/Formats/Textfile.cs b/SabreTools.Reports/Formats/Textfile.cs index 3e1e661c..33a510a2 100644 --- a/SabreTools.Reports/Formats/Textfile.cs +++ b/SabreTools.Reports/Formats/Textfile.cs @@ -11,7 +11,7 @@ namespace SabreTools.Reports.Formats /// /// Textfile report format /// - internal class Textfile : BaseReport + public class Textfile : BaseReport { protected bool _writeToConsole = false; @@ -129,7 +129,7 @@ namespace SabreTools.Reports.Formats /// /// Console report format /// - internal sealed class ConsoleOutput : Textfile + public sealed class ConsoleOutput : Textfile { /// /// Create a new report from the filename