mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Remove .NET Framework 4.6.2/4.7.2 (#24)
* Remove < .NET 4.8, general cleanup * Abstract * Tango * Banner * Scan no more * Common * Application * Access * Filter-feeder * Graffiti * Paint-over * Law and Order * XOR-o * Unused staircase * Maybe * Maybe not * Delete this * The word is "no" * Emit * Improper * Aye aye * Fence * Barrier * Monkey * Pail * Lines
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatFiles;
|
||||
using SabreTools.Library.Tools;
|
||||
|
||||
@@ -12,37 +13,35 @@ namespace SabreTools.Library.Reports
|
||||
/// TODO: Can this be overhauled to have all types write like DatFiles?
|
||||
public abstract class BaseReport
|
||||
{
|
||||
protected DatFile _datFile;
|
||||
protected string _name;
|
||||
protected long _machineCount;
|
||||
protected DatStats _stats;
|
||||
|
||||
protected StreamWriter _writer;
|
||||
protected bool _baddumpCol;
|
||||
protected bool _nodumpCol;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new report from the input DatFile and the filename
|
||||
/// Create a new report from the filename
|
||||
/// </summary>
|
||||
/// <param name="datfile">DatFile to write out statistics for</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>
|
||||
public BaseReport(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false)
|
||||
public BaseReport(string filename, bool baddumpCol = false, bool nodumpCol = false)
|
||||
{
|
||||
_datFile = datfile;
|
||||
_writer = new StreamWriter(Utilities.TryCreate(filename));
|
||||
_writer = new StreamWriter(FileExtensions.TryCreate(filename));
|
||||
_baddumpCol = baddumpCol;
|
||||
_nodumpCol = nodumpCol;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new report from the input DatFile and the stream
|
||||
/// Create a new report from the stream
|
||||
/// </summary>
|
||||
/// <param name="datfile">DatFile to write out statistics for</param>
|
||||
/// <param name="stream">Output stream to write 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>
|
||||
public BaseReport(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false)
|
||||
public BaseReport(Stream stream, bool baddumpCol = false, bool nodumpCol = false)
|
||||
{
|
||||
_datFile = datfile;
|
||||
|
||||
if (!stream.CanWrite)
|
||||
throw new ArgumentException(nameof(stream));
|
||||
|
||||
@@ -52,19 +51,67 @@ namespace SabreTools.Library.Reports
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace the DatFile that is being output
|
||||
/// Create a specific type of BaseReport to be used based on a format and user inputs
|
||||
/// </summary>
|
||||
/// <param name="datfile"></param>
|
||||
public void ReplaceDatFile(DatFile datfile)
|
||||
/// <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 Create(StatReportFormat statReportFormat, string filename, bool baddumpCol, bool nodumpCol)
|
||||
{
|
||||
_datFile = datfile;
|
||||
#if NET_FRAMEWORK
|
||||
switch (statReportFormat)
|
||||
{
|
||||
case StatReportFormat.None:
|
||||
return new Textfile(Console.OpenStandardOutput(), baddumpCol, nodumpCol);
|
||||
|
||||
case StatReportFormat.Textfile:
|
||||
return new Textfile(filename, baddumpCol, nodumpCol);
|
||||
|
||||
case StatReportFormat.CSV:
|
||||
return new SeparatedValue(filename, ',', baddumpCol, nodumpCol);
|
||||
|
||||
case StatReportFormat.HTML:
|
||||
return new Html(filename, baddumpCol, nodumpCol);
|
||||
|
||||
case StatReportFormat.SSV:
|
||||
return new SeparatedValue(filename, ';', baddumpCol, nodumpCol);
|
||||
|
||||
case StatReportFormat.TSV:
|
||||
return new SeparatedValue(filename, '\t', baddumpCol, nodumpCol);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
#else
|
||||
return statReportFormat switch
|
||||
{
|
||||
StatReportFormat.None => new Textfile(Console.OpenStandardOutput(), baddumpCol, nodumpCol),
|
||||
StatReportFormat.Textfile => new Textfile(filename, baddumpCol, nodumpCol),
|
||||
StatReportFormat.CSV => new SeparatedValue(filename, ',', baddumpCol, nodumpCol),
|
||||
StatReportFormat.HTML => new Html(filename, baddumpCol, nodumpCol),
|
||||
StatReportFormat.SSV => new SeparatedValue(filename, ';', baddumpCol, nodumpCol),
|
||||
StatReportFormat.TSV => new SeparatedValue(filename, '\t', baddumpCol, nodumpCol),
|
||||
_ => null,
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace the statistics that is being output
|
||||
/// </summary>
|
||||
public void ReplaceStatistics(string datName, long machineCount, DatStats datStats)
|
||||
{
|
||||
_name = datName;
|
||||
_machineCount = machineCount;
|
||||
_stats = datStats;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write the report to the output stream
|
||||
/// </summary>
|
||||
/// <param name="game">Number of games to use, -1 means use the number of keys</param>
|
||||
public abstract void Write(long game = -1);
|
||||
public abstract void Write();
|
||||
|
||||
/// <summary>
|
||||
/// Write out the header to the stream, if any exists
|
||||
|
||||
Reference in New Issue
Block a user