[DatFile, Reports/, Utilities] Make reports also in a factory

This commit is contained in:
Matt Nadareski
2017-11-17 15:08:35 -08:00
parent 7d1a578eb9
commit aa4a7b04ec
5 changed files with 33 additions and 25 deletions

View File

@@ -5702,25 +5702,7 @@ namespace SabreTools.Library.DatFiles
// Loop through and output based on the inputs
foreach (KeyValuePair<StatReportFormat, string> kvp in outputs)
{
// Create the proper report for this format
BaseReport report = null;
switch (kvp.Key)
{
case StatReportFormat.Textfile:
report = new Textfile(null, kvp.Value, baddumpCol, nodumpCol);
break;
case StatReportFormat.CSV:
report = new Reports.SeparatedValue(null, kvp.Value, ',', baddumpCol, nodumpCol);
break;
case StatReportFormat.HTML:
report = new Html(null, kvp.Value, baddumpCol, nodumpCol);
break;
case StatReportFormat.TSV:
report = new Reports.SeparatedValue(null, kvp.Value, '\t', baddumpCol, nodumpCol);
break;
}
reports.Add(report);
reports.Add(Utilities.CreateBaseReportFromType(kvp.Key, kvp.Value, baddumpCol, nodumpCol));
}
// Write the header, if any

View File

@@ -19,7 +19,7 @@ namespace SabreTools.Library.Reports
/// HTML report format
/// </summary>
/// TODO: Make output standard width, without making the entire thing a table
public class Html : BaseReport
internal class Html : BaseReport
{
/// <summary>
/// Create a new report from the input DatFile and the filename

View File

@@ -15,7 +15,7 @@ namespace SabreTools.Library.Reports
/// <summary>
/// Separated-Value report format
/// </summary>
public class SeparatedValue : BaseReport
internal class SeparatedValue : BaseReport
{
private char _separator;

View File

@@ -16,7 +16,7 @@ namespace SabreTools.Library.Reports
/// <summary>
/// Textfile report format
/// </summary>
public class Textfile : BaseReport
internal class Textfile : BaseReport
{
/// <summary>
/// Create a new report from the input DatFile and the filename

View File

@@ -11,9 +11,10 @@ using System.Xml.Schema;
using SabreTools.Library.Data;
using SabreTools.Library.DatFiles;
using SabreTools.Library.DatItems;
using SabreTools.Library.External;
using SabreTools.Library.FileTypes;
using SabreTools.Library.DatItems;
using SabreTools.Library.Reports;
using SabreTools.Library.Skippers;
#if MONO
@@ -552,7 +553,7 @@ namespace SabreTools.Library.Tools
case DatFormat.ClrMamePro:
return new ClrMamePro(baseDat);
case DatFormat.CSV:
return new SeparatedValue(baseDat, ',');
return new DatFiles.SeparatedValue(baseDat, ',');
case DatFormat.DOSCenter:
return new DosCenter(baseDat);
case DatFormat.Listroms:
@@ -582,7 +583,32 @@ namespace SabreTools.Library.Tools
case DatFormat.SoftwareList:
return new SoftwareList(baseDat);
case DatFormat.TSV:
return new SeparatedValue(baseDat, '\t');
return new DatFiles.SeparatedValue(baseDat, '\t');
}
return null;
}
/// <summary>
/// Create a specific type of BaseReport to be used based on a format and user inputs
/// </summary>
/// <param name="statReportFormat">Format of the Statistics Report to be created</param>
/// <param name="filename">Name of the file to write out to</param>
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
/// <returns>BaseReport of the specific internal type that corresponds to the inputs</returns>
public static BaseReport CreateBaseReportFromType(StatReportFormat statReportFormat, string filename, bool baddumpCol, bool nodumpCol)
{
switch (statReportFormat)
{
case StatReportFormat.Textfile:
return new Textfile(null, filename, baddumpCol, nodumpCol);
case StatReportFormat.CSV:
return new Reports.SeparatedValue(null, filename, ',', baddumpCol, nodumpCol);
case StatReportFormat.HTML:
return new Html(null, filename, baddumpCol, nodumpCol);
case StatReportFormat.TSV:
return new Reports.SeparatedValue(null, filename, '\t', baddumpCol, nodumpCol);
}
return null;