Printer was really redundant

This commit is contained in:
Matt Nadareski
2026-03-28 23:12:41 -04:00
parent d39c2e81d0
commit f1558587c3
2 changed files with 11 additions and 62 deletions

View File

@@ -179,12 +179,20 @@ namespace InfoPrint.Features
return;
}
// If the wrapper is not printable
if (wrapper is not IPrintable printable)
{
Console.WriteLine($"{ft} is not supported for printing!");
Console.WriteLine();
return;
}
#if NETCOREAPP
// If we have the JSON flag
if (Json)
{
// Create the output data
string serializedData = wrapper.ExportJSON();
string serializedData = printable.ExportJSON();
// Write the output data
using var jsw = new StreamWriter(File.OpenWrite($"{filenameBase}.json"));
@@ -194,12 +202,8 @@ namespace InfoPrint.Features
#endif
// Create the output data
var builder = wrapper.ExportStringBuilder();
if (builder is null)
{
Console.WriteLine("No item information could be generated");
return;
}
var builder = new StringBuilder();
printable.PrintInformation(builder);
// Only print to console if enabled
if (!FileOnly)

View File

@@ -1,55 +0,0 @@
using System;
using System.Text;
namespace SabreTools.Wrappers
{
/// <summary>
/// Generic wrapper around printing methods
/// </summary>
public static class Printer
{
/// <summary>
/// Print the item information from a wrapper to console as
/// pretty-printed text
/// </summary>
public static void PrintToConsole(this IWrapper wrapper)
{
var sb = wrapper.ExportStringBuilder();
if (sb is null)
{
Console.WriteLine("No item information could be generated");
return;
}
Console.WriteLine(sb.ToString());
}
/// <summary>
/// Export the item information as a StringBuilder
/// </summary>
public static StringBuilder? ExportStringBuilder(this IWrapper wrapper)
{
// Ignore unprintable types
if (wrapper is not IPrintable printable)
return null;
var builder = new StringBuilder();
printable.PrintInformation(builder);
return builder;
}
#if NETCOREAPP
/// <summary>
/// Export the item information as JSON
/// </summary>
public static string ExportJSON(this IWrapper wrapper)
{
// Ignore unprintable types
if (wrapper is not IPrintable printable)
return string.Empty;
return printable.ExportJSON();
}
#endif
}
}