mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Make Reports similar to DatFiles with access
This commit is contained in:
@@ -12,6 +12,7 @@ using SabreTools.DatItems;
|
|||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
using SabreTools.IO.Extensions;
|
using SabreTools.IO.Extensions;
|
||||||
using SabreTools.IO.Logging;
|
using SabreTools.IO.Logging;
|
||||||
|
using SabreTools.Reports;
|
||||||
|
|
||||||
namespace SabreTools.DatTools
|
namespace SabreTools.DatTools
|
||||||
{
|
{
|
||||||
@@ -29,6 +30,8 @@ namespace SabreTools.DatTools
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region DatFile
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a generic DatFile to be used
|
/// Create a generic DatFile to be used
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -508,5 +511,31 @@ namespace SabreTools.DatTools
|
|||||||
|
|
||||||
return line ?? string.Empty;
|
return line ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region BaseReport
|
||||||
|
|
||||||
|
/// <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="statsList">List of statistics objects to set</param>
|
||||||
|
/// <returns>BaseReport of the specific internal type that corresponds to the inputs</returns>
|
||||||
|
public static BaseReport? Create(StatReportFormat statReportFormat, List<DatStatistics> 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ namespace SabreTools.DatTools
|
|||||||
string outfile = outfiles[reportFormat];
|
string outfile = outfiles[reportFormat];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BaseReport.Create(reportFormat, stats)?.WriteToFile(outfile, baddumpCol, nodumpCol, throwOnError);
|
Parser.Create(reportFormat, stats)?.WriteToFile(outfile, baddumpCol, nodumpCol, throwOnError);
|
||||||
}
|
}
|
||||||
catch (Exception ex) when (!throwOnError)
|
catch (Exception ex) when (!throwOnError)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ namespace SabreTools.DatTools
|
|||||||
[
|
[
|
||||||
datFile.DatStatistics,
|
datFile.DatStatistics,
|
||||||
];
|
];
|
||||||
var consoleOutput = BaseReport.Create(StatReportFormat.None, statsList);
|
var consoleOutput = Parser.Create(StatReportFormat.None, statsList);
|
||||||
consoleOutput!.WriteToFile(null, true, true);
|
consoleOutput!.WriteToFile(null, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.IO.Logging;
|
using SabreTools.IO.Logging;
|
||||||
using SabreTools.Reports.Formats;
|
|
||||||
|
|
||||||
namespace SabreTools.Reports
|
namespace SabreTools.Reports
|
||||||
{
|
{
|
||||||
@@ -30,26 +29,6 @@ namespace SabreTools.Reports
|
|||||||
Statistics = statsList;
|
Statistics = statsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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="statsList">List of statistics objects to set</param>
|
|
||||||
/// <returns>BaseReport of the specific internal type that corresponds to the inputs</returns>
|
|
||||||
public static BaseReport? Create(StatReportFormat statReportFormat, List<DatStatistics> 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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create and open an output file for writing direct from a set of statistics
|
/// Create and open an output file for writing direct from a set of statistics
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SabreTools.Reports.Formats
|
|||||||
/// HTML report format
|
/// HTML report format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO: Make output standard width, without making the entire thing a table
|
/// TODO: Make output standard width, without making the entire thing a table
|
||||||
internal class Html : BaseReport
|
public class Html : BaseReport
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new report from the filename
|
/// Create a new report from the filename
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace SabreTools.Reports.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Separated-Value report format
|
/// Separated-Value report format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal abstract class SeparatedValue : BaseReport
|
public abstract class SeparatedValue : BaseReport
|
||||||
{
|
{
|
||||||
// Private instance variables specific to Hashfile DATs
|
// Private instance variables specific to Hashfile DATs
|
||||||
protected char _delim;
|
protected char _delim;
|
||||||
@@ -161,7 +161,7 @@ namespace SabreTools.Reports.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a comma-separated value file
|
/// Represents a comma-separated value file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class CommaSeparatedValue : SeparatedValue
|
public sealed class CommaSeparatedValue : SeparatedValue
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new report from the filename
|
/// Create a new report from the filename
|
||||||
@@ -176,7 +176,7 @@ namespace SabreTools.Reports.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a semicolon-separated value file
|
/// Represents a semicolon-separated value file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class SemicolonSeparatedValue : SeparatedValue
|
public sealed class SemicolonSeparatedValue : SeparatedValue
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new report from the filename
|
/// Create a new report from the filename
|
||||||
@@ -191,7 +191,7 @@ namespace SabreTools.Reports.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a tab-separated value file
|
/// Represents a tab-separated value file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class TabSeparatedValue : SeparatedValue
|
public sealed class TabSeparatedValue : SeparatedValue
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new report from the filename
|
/// Create a new report from the filename
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace SabreTools.Reports.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Textfile report format
|
/// Textfile report format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class Textfile : BaseReport
|
public class Textfile : BaseReport
|
||||||
{
|
{
|
||||||
protected bool _writeToConsole = false;
|
protected bool _writeToConsole = false;
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ namespace SabreTools.Reports.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Console report format
|
/// Console report format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class ConsoleOutput : Textfile
|
public sealed class ConsoleOutput : Textfile
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new report from the filename
|
/// Create a new report from the filename
|
||||||
|
|||||||
Reference in New Issue
Block a user