diff --git a/InfoPrint/Features/MainFeature.cs b/InfoPrint/Features/MainFeature.cs index 0e912161..4e2260bb 100644 --- a/InfoPrint/Features/MainFeature.cs +++ b/InfoPrint/Features/MainFeature.cs @@ -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) diff --git a/SabreTools.Wrappers/Printer.cs b/SabreTools.Wrappers/Printer.cs deleted file mode 100644 index 9a96fc7e..00000000 --- a/SabreTools.Wrappers/Printer.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Text; - -namespace SabreTools.Wrappers -{ - /// - /// Generic wrapper around printing methods - /// - public static class Printer - { - /// - /// Print the item information from a wrapper to console as - /// pretty-printed text - /// - 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()); - } - - /// - /// Export the item information as a StringBuilder - /// - 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 - /// - /// Export the item information as JSON - /// - public static string ExportJSON(this IWrapper wrapper) - { - // Ignore unprintable types - if (wrapper is not IPrintable printable) - return string.Empty; - - return printable.ExportJSON(); - } -#endif - } -}