Make printing a wrapper extension

This commit is contained in:
Matt Nadareski
2025-10-29 08:53:14 -04:00
parent 36c2cc2f15
commit 1d00abd6cc
82 changed files with 794 additions and 1010 deletions

View File

@@ -99,8 +99,8 @@ Below is a table representing the various non-conversion interfaces that are imp
| Interface Name | Purpose |
| --- | --- |
| `SabreTools.Data.Printers.IPrinter<TModel>` | Provides a formatted output for a `TModel` |
| `SabreTools.Serialization.Wrappers.IExtractable` | Marks a wrapper as able to be extracted |
| `SabreTools.Serialization.Wrappers.IPrintable` | Marks a wrapper as able to print model information |
| `SabreTools.Serialization.Wrappers.IWrapper` | Represents an item with a description and JSON serializable state, allowing for extensions |
| `SabreTools.Serialization.Wrappers.IWrapper<TModel>` | Wraps a model with source data, allowing for extensions |
@@ -114,7 +114,6 @@ Below is a table of all namespaces within the library and what they represent
| `SabreTools.Data.Extensions` | Extension methods related to models |
| `SabreTools.Data.Models` | Models representing different file and structure types |
| `SabreTools.Data.ObjectIdentifier` | Object Identifier (OID) parsing |
| `SabreTools.Data.Printers` | Export model information in a formatted manner |
| `SabreTools.Serialization.CrossModel` | Convert between models; mainly used for metadata files converting to and from a common, `Dictionary`-based model |
| `SabreTools.Serialization.Interfaces` | Interfaces used commonly throughout the library |
| `SabreTools.Serialization.Readers` | Convert from external sources to models |

View File

@@ -4,6 +4,12 @@ namespace SabreTools.Data.Extensions
{
public static class ISO9660
{
/// <summary>
/// Get the logical block size from a sector length
/// </summary>
/// <param name="bvd">Volume descriptor containing block information</param>
/// <param name="sectorLength">Defined sector length</param>
/// <returns>Size of a logical block</returns>
public static short GetLogicalBlockSize(this BaseVolumeDescriptor bvd, short sectorLength)
{
short blockLength = sectorLength;

View File

@@ -2,7 +2,7 @@ using System;
using System.Text;
using SabreTools.Numerics;
namespace SabreTools.Data.Printers
namespace SabreTools.Data.Extensions
{
// TODO: Add extension for printing enums, if possible
internal static class StringBuilderExtensions

View File

@@ -53,7 +53,7 @@ namespace SabreTools.Data.Models.ISO9660
/// <summary>
/// Record attributes
/// Note: If RecordType is zero, this field is ignored by readers
/// Note: If RecordType is zero, this field is ignored by readers
/// </summary>
public RecordAttributes RecordAttributes { get; set; }

View File

@@ -1,7 +1,6 @@
using System;
using System.Text;
using SabreTools.Data.Printers;
using Wrapper = SabreTools.Serialization.Wrappers;
using SabreTools.Serialization.Wrappers;
namespace SabreTools.Serialization
{
@@ -14,9 +13,9 @@ namespace SabreTools.Serialization
/// Print the item information from a wrapper to console as
/// pretty-printed text
/// </summary>
public static void PrintToConsole(this Wrapper.IWrapper wrapper)
public static void PrintToConsole(this IWrapper wrapper)
{
var sb = wrapper.ExportStringBuilder();
var sb = ExportStringBuilder(wrapper);
if (sb == null)
{
Console.WriteLine("No item information could be generated");
@@ -29,569 +28,29 @@ namespace SabreTools.Serialization
/// <summary>
/// Export the item information as a StringBuilder
/// </summary>
public static StringBuilder? ExportStringBuilder(this Wrapper.IWrapper wrapper)
public static StringBuilder? ExportStringBuilder(this IWrapper wrapper)
{
return wrapper switch
{
Wrapper.AACSMediaKeyBlock item => item.PrettyPrint(),
Wrapper.BDPlusSVM item => item.PrettyPrint(),
Wrapper.BFPK item => item.PrettyPrint(),
Wrapper.BSP item => item.PrettyPrint(),
Wrapper.CFB item => item.PrettyPrint(),
Wrapper.CHD item => item.PrettyPrint(),
Wrapper.CIA item => item.PrettyPrint(),
Wrapper.GCF item => item.PrettyPrint(),
Wrapper.GZip item => item.PrettyPrint(),
Wrapper.InstallShieldArchiveV3 item => item.PrettyPrint(),
Wrapper.InstallShieldCabinet item => item.PrettyPrint(),
Wrapper.IRD item => item.PrettyPrint(),
Wrapper.ISO9660 item => item.PrettyPrint(),
Wrapper.LinearExecutable item => item.PrettyPrint(),
Wrapper.LZKWAJ item => item.PrettyPrint(),
Wrapper.LZQBasic item => item.PrettyPrint(),
Wrapper.LZSZDD item => item.PrettyPrint(),
Wrapper.MicrosoftCabinet item => item.PrettyPrint(),
Wrapper.MoPaQ item => item.PrettyPrint(),
Wrapper.MSDOS item => item.PrettyPrint(),
Wrapper.N3DS item => item.PrettyPrint(),
Wrapper.NCF item => item.PrettyPrint(),
Wrapper.NewExecutable item => item.PrettyPrint(),
Wrapper.Nitro item => item.PrettyPrint(),
Wrapper.PAK item => item.PrettyPrint(),
Wrapper.PFF item => item.PrettyPrint(),
Wrapper.PIC item => item.PrettyPrint(),
Wrapper.PKZIP item => item.PrettyPrint(),
Wrapper.PlayJAudioFile item => item.PrettyPrint(),
Wrapper.PlayJPlaylist item => item.PrettyPrint(),
Wrapper.PortableExecutable item => item.PrettyPrint(),
Wrapper.Quantum item => item.PrettyPrint(),
Wrapper.SecuROMDFA item => item.PrettyPrint(),
Wrapper.SGA item => item.PrettyPrint(),
Wrapper.TapeArchive item => item.PrettyPrint(),
Wrapper.VBSP item => item.PrettyPrint(),
Wrapper.VPK item => item.PrettyPrint(),
Wrapper.WAD3 item => item.PrettyPrint(),
Wrapper.WiseOverlayHeader item => item.PrettyPrint(),
Wrapper.WiseScript item => item.PrettyPrint(),
Wrapper.WiseSectionHeader item => item.PrettyPrint(),
Wrapper.XeMID item => item.PrettyPrint(),
Wrapper.XMID item => item.PrettyPrint(),
Wrapper.XZ item => item.PrettyPrint(),
Wrapper.XZP item => item.PrettyPrint(),
_ => null,
};
// 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 Wrapper.IWrapper wrapper)
public static string ExportJSON(this IWrapper wrapper)
{
return wrapper switch
{
Wrapper.AACSMediaKeyBlock item => item.ExportJSON(),
Wrapper.BDPlusSVM item => item.ExportJSON(),
Wrapper.BFPK item => item.ExportJSON(),
Wrapper.BSP item => item.ExportJSON(),
Wrapper.CFB item => item.ExportJSON(),
Wrapper.CHD item => item.ExportJSON(),
Wrapper.CIA item => item.ExportJSON(),
Wrapper.GCF item => item.ExportJSON(),
Wrapper.GZip item => item.ExportJSON(),
Wrapper.InstallShieldArchiveV3 item => item.ExportJSON(),
Wrapper.InstallShieldCabinet item => item.ExportJSON(),
Wrapper.IRD item => item.ExportJSON(),
Wrapper.ISO9660 item => item.ExportJSON(),
Wrapper.LinearExecutable item => item.ExportJSON(),
Wrapper.LZKWAJ item => item.ExportJSON(),
Wrapper.LZQBasic item => item.ExportJSON(),
Wrapper.LZSZDD item => item.ExportJSON(),
Wrapper.MicrosoftCabinet item => item.ExportJSON(),
Wrapper.MoPaQ item => item.ExportJSON(),
Wrapper.MSDOS item => item.ExportJSON(),
Wrapper.N3DS item => item.ExportJSON(),
Wrapper.NCF item => item.ExportJSON(),
Wrapper.NewExecutable item => item.ExportJSON(),
Wrapper.Nitro item => item.ExportJSON(),
Wrapper.PAK item => item.ExportJSON(),
Wrapper.PFF item => item.ExportJSON(),
Wrapper.PIC item => item.ExportJSON(),
Wrapper.PKZIP item => item.ExportJSON(),
Wrapper.PlayJAudioFile item => item.ExportJSON(),
Wrapper.PlayJPlaylist item => item.ExportJSON(),
Wrapper.PortableExecutable item => item.ExportJSON(),
Wrapper.Quantum item => item.ExportJSON(),
Wrapper.SecuROMDFA item => item.ExportJSON(),
Wrapper.SGA item => item.ExportJSON(),
Wrapper.TapeArchive item => item.ExportJSON(),
Wrapper.VBSP item => item.ExportJSON(),
Wrapper.VPK item => item.ExportJSON(),
Wrapper.WAD3 item => item.ExportJSON(),
Wrapper.WiseOverlayHeader item => item.ExportJSON(),
Wrapper.WiseScript item => item.ExportJSON(),
Wrapper.WiseSectionHeader item => item.ExportJSON(),
Wrapper.XeMID item => item.ExportJSON(),
Wrapper.XMID item => item.ExportJSON(),
Wrapper.XZ item => item.ExportJSON(),
Wrapper.XZP item => item.ExportJSON(),
_ => string.Empty,
};
// Ignore unprintable types
if (wrapper is not IPrintable printable)
return string.Empty;
return printable.ExportJSON();
}
#endif
#region Static Printing Implementations
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.AACSMediaKeyBlock item)
{
var builder = new StringBuilder();
AACSMediaKeyBlock.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.BDPlusSVM item)
{
var builder = new StringBuilder();
BDPlusSVM.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.BFPK item)
{
var builder = new StringBuilder();
BFPK.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.BSP item)
{
var builder = new StringBuilder();
BSP.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.CFB item)
{
var builder = new StringBuilder();
CFB.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.CHD item)
{
var builder = new StringBuilder();
CHD.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.CIA item)
{
var builder = new StringBuilder();
CIA.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.GCF item)
{
var builder = new StringBuilder();
GCF.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.GZip item)
{
var builder = new StringBuilder();
GZip.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.InstallShieldArchiveV3 item)
{
var builder = new StringBuilder();
InstallShieldArchiveV3.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.InstallShieldCabinet item)
{
var builder = new StringBuilder();
InstallShieldCabinet.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.IRD item)
{
var builder = new StringBuilder();
IRD.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.ISO9660 item)
{
var builder = new StringBuilder();
ISO9660.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.LinearExecutable item)
{
var builder = new StringBuilder();
LinearExecutable.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.LZKWAJ item)
{
var builder = new StringBuilder();
LZKWAJ.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.LZQBasic item)
{
var builder = new StringBuilder();
LZQBasic.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.LZSZDD item)
{
var builder = new StringBuilder();
LZSZDD.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.MicrosoftCabinet item)
{
var builder = new StringBuilder();
MicrosoftCabinet.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.MoPaQ item)
{
var builder = new StringBuilder();
MoPaQ.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.MSDOS item)
{
var builder = new StringBuilder();
MSDOS.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.N3DS item)
{
var builder = new StringBuilder();
N3DS.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.NCF item)
{
var builder = new StringBuilder();
NCF.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.NewExecutable item)
{
var builder = new StringBuilder();
NewExecutable.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.Nitro item)
{
var builder = new StringBuilder();
Nitro.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.PAK item)
{
var builder = new StringBuilder();
PAK.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.PFF item)
{
var builder = new StringBuilder();
PFF.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.PIC item)
{
var builder = new StringBuilder();
PIC.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.PKZIP item)
{
var builder = new StringBuilder();
PKZIP.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.PlayJAudioFile item)
{
var builder = new StringBuilder();
PlayJAudioFile.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.PlayJPlaylist item)
{
var builder = new StringBuilder();
PlayJPlaylist.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.PortableExecutable item)
{
var builder = new StringBuilder();
PortableExecutable.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.Quantum item)
{
var builder = new StringBuilder();
Quantum.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.SecuROMDFA item)
{
var builder = new StringBuilder();
SecuROMDFA.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.SGA item)
{
var builder = new StringBuilder();
SGA.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.TapeArchive item)
{
var builder = new StringBuilder();
TapeArchive.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.VBSP item)
{
var builder = new StringBuilder();
VBSP.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.VPK item)
{
var builder = new StringBuilder();
VPK.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.WAD3 item)
{
var builder = new StringBuilder();
WAD3.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.WiseOverlayHeader item)
{
var builder = new StringBuilder();
WiseOverlayHeader.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.WiseScript item)
{
var builder = new StringBuilder();
WiseScript.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.WiseSectionHeader item)
{
var builder = new StringBuilder();
WiseSectionHeader.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.XeMID item)
{
var builder = new StringBuilder();
XeMID.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.XMID item)
{
var builder = new StringBuilder();
XMID.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.XZ item)
{
var builder = new StringBuilder();
XZ.Print(builder, item.Model);
return builder;
}
/// <summary>
/// Export the item information as pretty-printed text
/// </summary>
private static StringBuilder PrettyPrint(this Wrapper.XZP item)
{
var builder = new StringBuilder();
XZP.Print(builder, item.Model);
return builder;
}
#endregion
}
}

View File

@@ -1,18 +0,0 @@
using System.Text;
namespace SabreTools.Data.Printers
{
/// <summary>
/// Marks a class as a printer associated with a model
/// </summary>
/// <typeparam name="TModel">Type of the top-level model</typeparam>
public interface IPrinter<TModel>
{
/// <summary>
/// Print information associated with a model
/// </summary>
/// <param name="builder">StringBuilder to append information to</param>
/// <param name="model">Model to print</param>
void PrintInformation(StringBuilder builder, TModel model);
}
}

View File

@@ -1,17 +1,16 @@
using System;
using System.Collections.Generic;
using System.IO;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.ISO9660;
using SabreTools.IO.Extensions;
using SabreTools.Numerics;
namespace SabreTools.Serialization.Readers
{
public class ISO9660 : BaseBinaryReader<Volume>
{
/// <inheritdoc/>
public override Volume? Deserialize(Stream? data) => Deserialize(data, Constants.MinimumSectorSize);
public override Volume? Deserialize(Stream? data)
=> Deserialize(data, Constants.MinimumSectorSize);
/// <inheritdoc cref="Deserialize(Stream?)" />
/// <param name="sectorLength">Size of the logical sector used in the volume</param>
@@ -84,7 +83,7 @@ namespace SabreTools.Serialization.Readers
// If no valid volume descriptor could be read, return the current set
if (volumeDescriptor == null)
return [.. obj];
// If the set has already been terminated and the returned volume descriptor is not another terminator,
// assume the read volume descriptor is not a valid volume descriptor and return the current set
if (setTerminated && volumeDescriptor.Type != VolumeDescriptorType.VOLUME_DESCRIPTOR_SET_TERMINATOR)
@@ -93,7 +92,7 @@ namespace SabreTools.Serialization.Readers
data.Seek(-sectorLength, SeekOrigin.Current);
return [.. obj];
}
// Add the valid read volume descriptor to the set
obj.Add(volumeDescriptor);
@@ -397,7 +396,7 @@ namespace SabreTools.Serialization.Readers
}
}
// Return error (null) if no valid path table groups were found
// Return error (null) if no valid path table groups were found
if (groups.Count == 0)
return null;
@@ -421,7 +420,7 @@ namespace SabreTools.Serialization.Readers
int locationL2 = vd.OptionalPathTableLocationL;
int locationM = vd.PathTableLocationM;
int locationM2 = vd.OptionalPathTableLocationM;
short blockLength = vd.GetLogicalBlockSize(sectorLength);
var groupL = new PathTableGroup();
@@ -453,7 +452,7 @@ namespace SabreTools.Serialization.Readers
// If the both-endian path table size value is consistent, return the single path table group
if (sizeL == sizeB)
return groups;
// Get the other-sized path table group
var groupB = new PathTableGroup();
if (locationL != 0 && ((locationL * blockLength) + sizeB) < data.Length)
@@ -582,7 +581,7 @@ namespace SabreTools.Serialization.Readers
}
}
// Return error (null) if no valid directory descriptors were found
// Return error (null) if no valid directory descriptors were found
if (directories.Count == 0)
return null;

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.AACS;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class AACSMediaKeyBlock : IPrinter<MediaKeyBlock>
public partial class AACSMediaKeyBlock : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, MediaKeyBlock model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, MediaKeyBlock mediaKeyBlock)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, MediaKeyBlock mediaKeyBlock)
{
builder.AppendLine("AACS Media Key Block Information:");
builder.AppendLine("-------------------------");

View File

@@ -4,7 +4,7 @@ using SabreTools.Data.Models.AACS;
namespace SabreTools.Serialization.Wrappers
{
public class AACSMediaKeyBlock : WrapperBase<MediaKeyBlock>
public partial class AACSMediaKeyBlock : WrapperBase<MediaKeyBlock>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.BDPlus;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class BDPlusSVM : IPrinter<SVM>
public partial class BDPlusSVM : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, SVM model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, SVM svm)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, SVM svm)
{
builder.AppendLine("BD+ SVM Information:");
builder.AppendLine("-------------------------");

View File

@@ -3,7 +3,7 @@ using SabreTools.Data.Models.BDPlus;
namespace SabreTools.Serialization.Wrappers
{
public class BDPlusSVM : WrapperBase<SVM>
public partial class BDPlusSVM : WrapperBase<SVM>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.BFPK;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class BFPK : IPrinter<Archive>
public partial class BFPK : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive archive)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive archive)
{
builder.AppendLine("BFPK Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.BSP;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class BSP : IPrinter<BspFile>
public partial class BSP : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, BspFile model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, BspFile file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, BspFile file)
{
builder.AppendLine("BSP Information:");
builder.AppendLine("-------------------------");

View File

@@ -77,15 +77,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => throw new System.NotImplementedException();
#endif
#endregion
}
}

View File

@@ -1,16 +1,22 @@
using System;
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.CFB;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class CFB : IPrinter<Binary>
public partial class CFB : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Binary model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Binary binary)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Binary binary)
{
builder.AppendLine("Compound File Binary Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,17 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.CHD;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class CHD : IPrinter<Header>
public partial class CHD : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Header model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Header header)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Header header)
{
builder.AppendLine("CHD Header Information:");
builder.AppendLine("-------------------------");

View File

@@ -3,7 +3,7 @@ using SabreTools.Data.Models.CHD;
namespace SabreTools.Serialization.Wrappers
{
public class CHD : WrapperBase<Header>
public partial class CHD : WrapperBase<Header>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.N3DS;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class CIA : IPrinter<Models.N3DS.CIA>
public partial class CIA : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Models.N3DS.CIA model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Models.N3DS.CIA cia)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Data.Models.N3DS.CIA cia)
{
builder.AppendLine("CIA Archive Information:");
builder.AppendLine("-------------------------");

View File

@@ -3,7 +3,7 @@ using SabreTools.Data.Models.N3DS;
namespace SabreTools.Serialization.Wrappers
{
public class CIA : WrapperBase<Data.Models.N3DS.CIA>
public partial class CIA : WrapperBase<Data.Models.N3DS.CIA>
{
#region Descriptive Properties

View File

@@ -1,16 +1,22 @@
using System.Collections.Generic;
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.GCF;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class GCF : IPrinter<File>
public partial class GCF : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, File model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, File file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, File file)
{
builder.AppendLine("GCF Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.GZIP;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class GZip : IPrinter<Archive>
public partial class GZip : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive file)
{
builder.AppendLine("gzip Information:");
builder.AppendLine("-------------------------");

View File

@@ -0,0 +1,23 @@
using System.Text;
namespace SabreTools.Serialization.Wrappers
{
/// <summary>
/// Marks a wrapper as being able to print model information
/// </summary>
public interface IPrintable
{
#if NETCOREAPP
/// <summary>
/// Export the item information as JSON
/// </summary>
string ExportJSON();
#endif
/// <summary>
/// Print information associated with a model
/// </summary>
/// <param name="builder">StringBuilder to append information to</param>
void PrintInformation(StringBuilder builder);
}
}

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.IRD;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class IRD : IPrinter<File>
public partial class IRD : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, File model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, File ird)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, File ird)
{
builder.AppendLine("IRD Information:");
builder.AppendLine("-------------------------");

View File

@@ -2,7 +2,7 @@ using System.IO;
namespace SabreTools.Serialization.Wrappers
{
public class IRD : WrapperBase<Data.Models.IRD.File>
public partial class IRD : WrapperBase<Data.Models.IRD.File>
{
#region Descriptive Properties

View File

@@ -1,18 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.ISO9660;
using SabreTools.Numerics;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class ISO9660 : IPrinter<Volume>
public partial class ISO9660 : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Volume model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Volume volume)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Volume volume)
{
builder.AppendLine("ISO 9660 Information:");
builder.AppendLine("-------------------------");
@@ -83,7 +88,7 @@ namespace SabreTools.Data.Printers
}
private static void Print(StringBuilder builder, BaseVolumeDescriptor vd)
{
{
// TOOD: Determine encoding based on vd.Type, svd.EscapeSequence (and manual detection?)
if (vd.Type == VolumeDescriptorType.PRIMARY_VOLUME_DESCRIPTOR)
@@ -117,7 +122,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine(vd.SystemIdentifier, " System Identifier");
builder.AppendLine(vd.VolumeIdentifier, " Volume Identifier");
if (vd.Unused8Bytes != null && Array.TrueForAll(vd.Unused8Bytes, b => b == 0))
builder.AppendLine("Zeroed", " Unused 8 Bytes");
else
@@ -146,7 +151,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine(vd.OptionalPathTableLocationL, " Optional Type-L Path Table Location");
builder.AppendLine(vd.PathTableLocationM, " Type-M Path Table Location");
builder.AppendLine(vd.OptionalPathTableLocationM, " Optional Type-M Path Table Location");
builder.AppendLine(" Root Directory Record:");
Print(builder, vd.RootDirectoryRecord);
@@ -342,7 +347,7 @@ namespace SabreTools.Data.Printers
return;
}
foreach(var kvp in dirs)
foreach (var kvp in dirs)
{
builder.AppendLine($" Directory at Sector {kvp.Key}");
builder.AppendLine(" -------------------------");
@@ -394,7 +399,7 @@ namespace SabreTools.Data.Printers
builder.AppendLineBothEndian(dr.ExtentLength, " Extent Length");
Print(builder, dr.RecordingDateTime);
builder.AppendLine(" File Flags:");
builder.AppendLine((dr.FileFlags & FileFlags.EXISTENCE) == FileFlags.EXISTENCE, " Existence");
builder.AppendLine((dr.FileFlags & FileFlags.DIRECTORY) == FileFlags.DIRECTORY, " Directory");
@@ -413,7 +418,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine(dr.FileIdentifierLength, " File Identifier Length");
builder.AppendLine(dr.FileIdentifier, " File Identifier");
builder.AppendLine(dr.PaddingField, " Padding Field");
if (dr.SystemUse == null || dr.SystemUse.Length == 0)
builder.AppendLine(dr.SystemUse, " System Use");
else if (Array.TrueForAll(dr.SystemUse, b => b == 0))
@@ -437,7 +442,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine(drdt.Hour, " Hour");
builder.AppendLine(drdt.Minute, " Minute");
builder.AppendLine(drdt.Second, " Second");
string tz = $"{((drdt.TimezoneOffset-48)*15/60):+0;-0}:{((drdt.TimezoneOffset-48)*15%60+60)%60:00} (0x{drdt.TimezoneOffset.ToString("X2")})";
string tz = $"{((drdt.TimezoneOffset - 48) * 15 / 60):+0;-0}:{((drdt.TimezoneOffset - 48) * 15 % 60 + 60) % 60:00} (0x{drdt.TimezoneOffset.ToString("X2")})";
builder.AppendLine(tz, " Timezone Offset");
}
@@ -450,7 +455,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine(" [NULL]");
return;
}
if (IsDigits(dt.Year))
builder.AppendLine(Encoding.ASCII.GetString(dt.Year), " Year");
else
@@ -479,7 +484,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine(Encoding.ASCII.GetString(dt.Centisecond), " Centisecond");
else
builder.AppendLine(dt.Centisecond, " Centisecond");
string tz = $"{((dt.TimezoneOffset-48)*15/60):+0;-0}:{((dt.TimezoneOffset-48)*15%60+60)%60:00} (0x{dt.TimezoneOffset.ToString("X2")})";
string tz = $"{((dt.TimezoneOffset - 48) * 15 / 60):+0;-0}:{((dt.TimezoneOffset - 48) * 15 % 60 + 60) % 60:00} (0x{dt.TimezoneOffset.ToString("X2")})";
builder.AppendLine(tz, " Timezone Offset");
}

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;
using SabreTools.Data.Models.ISO9660;
@@ -16,19 +15,13 @@ namespace SabreTools.Serialization.Wrappers
#region Extension Properties
/// <summary>
/// Volume Descriptors
/// </summary>
/// <inheritdoc cref="Volume.VolumeDescriptorSet"/>
public VolumeDescriptor[] VolumeDescriptorSet => Model.VolumeDescriptorSet ?? [];
/// <summary>
/// Path Tables
/// </summary>
/// <inheritdoc cref="Volume.PathTableGroups"/>
public PathTableGroup[] PathTableGroups => Model.PathTableGroups ?? [];
/// <summary>
/// Directory Descriptors
/// </summary>
/// <inheritdoc cref="Volume.DirectoryDescriptors"/>
public Dictionary<int, DirectoryExtent> DirectoryDescriptors => Model.DirectoryDescriptors ?? [];
#endregion

View File

@@ -9,12 +9,5 @@ namespace SabreTools.Serialization.Wrappers
/// Get a human-readable description of the wrapper
/// </summary>
string Description();
#if NETCOREAPP
/// <summary>
/// Export the item information as JSON
/// </summary>
string ExportJSON();
#endif
}
}

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.InstallShieldArchiveV3;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class InstallShieldArchiveV3 : IPrinter<Archive>
public partial class InstallShieldArchiveV3 : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive archive)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive archive)
{
builder.AppendLine("InstallShield Archive V3 Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,16 +1,22 @@
using System.Collections.Generic;
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.InstallShieldCabinet;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class InstallShieldCabinet : IPrinter<Cabinet>
public partial class InstallShieldCabinet : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Cabinet model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Cabinet cabinet)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Cabinet cabinet)
{
builder.AppendLine("InstallShield Cabinet Information:");
builder.AppendLine("-------------------------");

View File

@@ -77,15 +77,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => throw new System.NotImplementedException();
#endif
#endregion
}
}

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.LZ;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class LZKWAJ : IPrinter<KWAJFile>
public partial class LZKWAJ : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, KWAJFile model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, KWAJFile file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, KWAJFile file)
{
builder.AppendLine("LZ-compressed File, KWAJ Variant Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.LZ;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class LZQBasic : IPrinter<QBasicFile>
public partial class LZQBasic : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, QBasicFile model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, QBasicFile file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, QBasicFile file)
{
builder.AppendLine("LZ-compressed File, QBasic Variant Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.LZ;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class LZSZDD : IPrinter<SZDDFile>
public partial class LZSZDD : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, SZDDFile model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, SZDDFile file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, SZDDFile file)
{
builder.AppendLine("LZ-compressed File, SZDD Variant Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.LinearExecutable;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class LinearExecutable : IPrinter<Executable>
public partial class LinearExecutable : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Executable model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Executable executable)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Executable executable)
{
builder.AppendLine("New Executable Information:");
builder.AppendLine("-------------------------");
@@ -40,7 +46,7 @@ namespace SabreTools.Data.Printers
Print(builder, executable.DebugInformation);
}
private static void Print(StringBuilder builder, Models.MSDOS.ExecutableHeader? header)
private static void Print(StringBuilder builder, Data.Models.MSDOS.ExecutableHeader? header)
{
builder.AppendLine(" MS-DOS Stub Header Information:");
builder.AppendLine(" -------------------------");

View File

@@ -5,7 +5,7 @@ using SabreTools.IO.Extensions;
namespace SabreTools.Serialization.Wrappers
{
public class LinearExecutable : WrapperBase<Executable>
public partial class LinearExecutable : WrapperBase<Executable>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.MSDOS;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class MSDOS : IPrinter<Executable>
public partial class MSDOS : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Executable model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Executable executable)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Executable executable)
{
builder.AppendLine("MS-DOS Executable Information:");
builder.AppendLine("-------------------------");

View File

@@ -3,7 +3,7 @@ using SabreTools.Data.Models.MSDOS;
namespace SabreTools.Serialization.Wrappers
{
public class MSDOS : WrapperBase<Executable>
public partial class MSDOS : WrapperBase<Executable>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.MicrosoftCabinet;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class MicrosoftCabinet : IPrinter<Cabinet>
public partial class MicrosoftCabinet : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Cabinet model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Cabinet cabinet)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Cabinet cabinet)
{
builder.AppendLine("Microsoft Cabinet Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.MoPaQ;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class MoPaQ : IPrinter<Archive>
public partial class MoPaQ : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive archive)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive archive)
{
builder.AppendLine("MoPaQ Archive Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,16 +1,22 @@
using System;
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.N3DS;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class N3DS : IPrinter<Cart>
public partial class N3DS : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Cart model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Cart cart)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Cart cart)
{
builder.AppendLine("3DS Cart Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,16 +1,22 @@
using System.Collections.Generic;
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.NCF;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class NCF : IPrinter<File>
public partial class NCF : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, File model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, File file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, File file)
{
builder.AppendLine("NCF Information:");
builder.AppendLine("-------------------------");

View File

@@ -2,7 +2,7 @@ using System.IO;
namespace SabreTools.Serialization.Wrappers
{
public class NCF : WrapperBase<Data.Models.NCF.File>
public partial class NCF : WrapperBase<Data.Models.NCF.File>
{
#region Descriptive Properties

View File

@@ -3,15 +3,20 @@ using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.NewExecutable;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class NewExecutable : IPrinter<Executable>
public partial class NewExecutable : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Executable model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Executable executable)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Executable executable)
{
builder.AppendLine("New Executable Information:");
builder.AppendLine("-------------------------");
@@ -33,7 +38,7 @@ namespace SabreTools.Data.Printers
Print(builder, executable.NonResidentNameTable);
}
private static void Print(StringBuilder builder, Models.MSDOS.ExecutableHeader? header)
private static void Print(StringBuilder builder, Data.Models.MSDOS.ExecutableHeader? header)
{
builder.AppendLine(" MS-DOS Stub Header Information:");
builder.AppendLine(" -------------------------");
@@ -242,7 +247,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, ModuleReferenceTableEntry[]? entries, Models.MSDOS.ExecutableHeader? stub, ExecutableHeader? header)
private static void Print(StringBuilder builder, ModuleReferenceTableEntry[]? entries, Data.Models.MSDOS.ExecutableHeader? stub, ExecutableHeader? header)
{
builder.AppendLine(" Module-Reference Table Information:");
builder.AppendLine(" -------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.Nitro;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class Nitro : IPrinter<Cart>
public partial class Nitro : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Cart model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Cart cart)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Cart cart)
{
builder.AppendLine("NDS Cart Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.PAK;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class PAK : IPrinter<File>
public partial class PAK : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, File model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, File file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, File file)
{
builder.AppendLine("PAK Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.PFF;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class PFF : IPrinter<Archive>
public partial class PFF : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive archive)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive archive)
{
builder.AppendLine("PFF Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.PIC;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class PIC : IPrinter<DiscInformation>
public partial class PIC : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, DiscInformation model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, DiscInformation di)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, DiscInformation di)
{
builder.AppendLine("PIC Information:");
builder.AppendLine("-------------------------");

View File

@@ -3,7 +3,7 @@ using SabreTools.Data.Models.PIC;
namespace SabreTools.Serialization.Wrappers
{
public class PIC : WrapperBase<DiscInformation>
public partial class PIC : WrapperBase<DiscInformation>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.PKZIP;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class PKZIP : IPrinter<Archive>
public partial class PKZIP : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive archive)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive archive)
{
builder.AppendLine("PKZIP Archive (or Derived Format) Information:");
builder.AppendLine("-------------------------");
@@ -279,7 +285,7 @@ namespace SabreTools.Data.Printers
var entry = entries[i];
builder.AppendLine($" Extra Field {i}:");
builder.AppendLine($" Header ID: {entry.HeaderID} (0x{(byte)entry.HeaderID:X4})");
builder.AppendLine($" Header ID: {entry.HeaderID} (0x{(ushort)entry.HeaderID:X4})");
builder.AppendLine(entry.DataSize, " Data size");
switch (entry)
{

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.PlayJ;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class PlayJAudioFile : IPrinter<AudioFile>
public partial class PlayJAudioFile : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, AudioFile model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, AudioFile audio)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, AudioFile audio)
{
builder.AppendLine("PlayJ Audio File Information:");
builder.AppendLine("-------------------------");

View File

@@ -2,7 +2,7 @@ using System.IO;
namespace SabreTools.Serialization.Wrappers
{
public class PlayJAudioFile : WrapperBase<Data.Models.PlayJ.AudioFile>
public partial class PlayJAudioFile : WrapperBase<Data.Models.PlayJ.AudioFile>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.PlayJ;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class PlayJPlaylist : IPrinter<Playlist>
public partial class PlayJPlaylist : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Playlist model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Playlist playlist)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Playlist playlist)
{
builder.AppendLine("PlayJ Playlist Information:");
builder.AppendLine("-------------------------");

View File

@@ -2,7 +2,7 @@ using System.IO;
namespace SabreTools.Serialization.Wrappers
{
public class PlayJPlaylist : WrapperBase<Data.Models.PlayJ.Playlist>
public partial class PlayJPlaylist : WrapperBase<Data.Models.PlayJ.Playlist>
{
#region Descriptive Properties

View File

@@ -9,15 +9,20 @@ using SabreTools.Data.Models.PortableExecutable;
using SabreTools.Data.Models.PortableExecutable.Resource.Entries;
using SabreTools.IO.Extensions;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class PortableExecutable : IPrinter<Executable>
public partial class PortableExecutable : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Executable model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Executable executable)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Executable executable)
{
builder.AppendLine("Portable Executable Information:");
builder.AppendLine("-------------------------");
@@ -59,7 +64,7 @@ namespace SabreTools.Data.Printers
Print(builder, executable.DebugTable);
}
private static void Print(StringBuilder builder, Models.MSDOS.ExecutableHeader? header)
private static void Print(StringBuilder builder, Data.Models.MSDOS.ExecutableHeader? header)
{
builder.AppendLine(" MS-DOS Stub Header Information:");
builder.AppendLine(" -------------------------");
@@ -118,7 +123,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.OptionalHeader? header, SectionHeader[]? table)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.OptionalHeader? header, SectionHeader[]? table)
{
builder.AppendLine(" Optional Header Information:");
builder.AppendLine(" -------------------------");
@@ -416,7 +421,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine(entry.Reserved2, " Reserved");
}
private static void Print(StringBuilder builder, Models.COFF.StringTable? stringTable)
private static void Print(StringBuilder builder, Data.Models.COFF.StringTable? stringTable)
{
builder.AppendLine(" String Table Information:");
builder.AppendLine(" -------------------------");
@@ -438,7 +443,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.AttributeCertificate.Entry[]? entries)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.AttributeCertificate.Entry[]? entries)
{
builder.AppendLine(" Attribute Certificate Table Information:");
builder.AppendLine(" -------------------------");
@@ -479,7 +484,7 @@ namespace SabreTools.Data.Printers
}
else
{
foreach (Models.ASN1.TypeLengthValue tlv in topLevelValues)
foreach (Data.Models.ASN1.TypeLengthValue tlv in topLevelValues)
{
string tlvString = tlv.Format(paddingLevel: 4);
builder.AppendLine(tlvString);
@@ -505,7 +510,7 @@ namespace SabreTools.Data.Printers
}
}
private static void Print(StringBuilder builder, Models.PortableExecutable.DelayLoad.DirectoryTable? table, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.DelayLoad.DirectoryTable? table, SectionHeader[]? sections)
{
builder.AppendLine(" Delay-Load Directory Table Information:");
builder.AppendLine(" -------------------------");
@@ -532,7 +537,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.BaseRelocation.Block[]? entries, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.BaseRelocation.Block[]? entries, SectionHeader[]? sections)
{
builder.AppendLine(" Base Relocation Table Information:");
builder.AppendLine(" -------------------------");
@@ -575,7 +580,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.DebugData.Table? table)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.DebugData.Table? table)
{
builder.AppendLine(" Debug Table Information:");
builder.AppendLine(" -------------------------");
@@ -604,7 +609,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.DirectoryTable? table, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Export.DirectoryTable? table, SectionHeader[]? sections)
{
builder.AppendLine(value: " Export Directory Table Information:");
builder.AppendLine(" -------------------------");
@@ -634,7 +639,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.AddressTableEntry[]? table, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Export.AddressTableEntry[]? table, SectionHeader[]? sections)
{
builder.AppendLine(" Export Address Table Information:");
builder.AppendLine(" -------------------------");
@@ -657,7 +662,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.NamePointerTable? table)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Export.NamePointerTable? table)
{
builder.AppendLine(" Export Name Pointer Table Information:");
builder.AppendLine(" -------------------------");
@@ -679,7 +684,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.OrdinalTable? table)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Export.OrdinalTable? table)
{
builder.AppendLine(" Export Ordinal Table Information:");
builder.AppendLine(" -------------------------");
@@ -701,7 +706,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.NameTable? table)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Export.NameTable? table)
{
builder.AppendLine(" Export Name Table Information:");
builder.AppendLine(" -------------------------");
@@ -723,7 +728,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Import.DirectoryTableEntry[]? table, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Import.DirectoryTableEntry[]? table, SectionHeader[]? sections)
{
builder.AppendLine(" Import Directory Table Information:");
builder.AppendLine(" -------------------------");
@@ -753,7 +758,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Dictionary<int, Models.PortableExecutable.Import.LookupTableEntry[]?>? tables, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Dictionary<int, Data.Models.PortableExecutable.Import.LookupTableEntry[]?>? tables, SectionHeader[]? sections)
{
builder.AppendLine(" Import Lookup Tables Information:");
builder.AppendLine(" -------------------------");
@@ -799,7 +804,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Dictionary<int, Models.PortableExecutable.Import.AddressTableEntry[]?>? tables, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Dictionary<int, Data.Models.PortableExecutable.Import.AddressTableEntry[]?>? tables, SectionHeader[]? sections)
{
builder.AppendLine(" Import Address Tables Information:");
builder.AppendLine(" -------------------------");
@@ -845,7 +850,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Import.HintNameTableEntry[]? table)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Import.HintNameTableEntry[]? table)
{
builder.AppendLine(" Import Hint/Name Table Information:");
builder.AppendLine(" -------------------------");
@@ -868,7 +873,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Resource.DirectoryTable? table, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Resource.DirectoryTable? table, SectionHeader[]? sections)
{
builder.AppendLine(" Resource Directory Table Information:");
builder.AppendLine(" -------------------------");
@@ -883,7 +888,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Resource.DirectoryTable table, int level, List<object> types, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Resource.DirectoryTable table, int level, List<object> types, SectionHeader[]? sections)
{
string padding = new(' ', (level + 1) * 2);
@@ -923,7 +928,7 @@ namespace SabreTools.Data.Printers
}
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Resource.DirectoryEntry entry, int level, List<object> types, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Resource.DirectoryEntry entry, int level, List<object> types, SectionHeader[]? sections)
{
string padding = new(' ', (level + 1) * 2);
@@ -944,7 +949,7 @@ namespace SabreTools.Data.Printers
Print(builder, entry.Subdirectory, level: level + 1, types, sections);
}
private static void Print(StringBuilder builder, Models.PortableExecutable.Resource.DataEntry entry, int level, List<object> types, SectionHeader[]? sections)
private static void Print(StringBuilder builder, Data.Models.PortableExecutable.Resource.DataEntry entry, int level, List<object> types, SectionHeader[]? sections)
{
string padding = new(' ', (level + 1) * 2);
@@ -1040,25 +1045,25 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
private static void PrintResourceRT_CURSOR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_CURSOR(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Hardware-dependent cursor resource found, not parsed yet");
}
private static void PrintResourceRT_BITMAP(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_BITMAP(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Bitmap resource found, not parsed yet");
}
private static void PrintResourceRT_ICON(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_ICON(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Hardware-dependent icon resource found, not parsed yet");
}
private static void PrintResourceRT_MENU(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_MENU(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
@@ -1136,7 +1141,7 @@ namespace SabreTools.Data.Printers
}
}
private static void PrintResourceRT_DIALOG(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_DIALOG(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
@@ -1271,7 +1276,7 @@ namespace SabreTools.Data.Printers
}
}
private static void PrintResourceRT_STRING(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_STRING(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
@@ -1291,19 +1296,19 @@ namespace SabreTools.Data.Printers
}
}
private static void PrintResourceRT_FONTDIR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_FONTDIR(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Font directory resource found, not parsed yet");
}
private static void PrintResourceRT_FONT(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_FONT(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Font resource found, not parsed yet");
}
private static void PrintResourceRT_ACCELERATOR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_ACCELERATOR(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
@@ -1326,7 +1331,7 @@ namespace SabreTools.Data.Printers
}
}
private static void PrintResourceRT_RCDATA(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_RCDATA(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Application-defined resource found, not parsed yet");
@@ -1361,11 +1366,11 @@ namespace SabreTools.Data.Printers
{
builder.AppendLine($"{padding}Data: [Embedded spanned PKZIP file]"); // TODO: Parse this out and print separately
}
else if (magic.StartsWith(Models.RAR.Constants.OldSignatureBytes))
else if (magic.StartsWith(Data.Models.RAR.Constants.OldSignatureBytes))
{
builder.AppendLine($"{padding}Data: [Embedded RAR file]"); // TODO: Parse this out and print separately
}
else if (magic.StartsWith(Models.RAR.Constants.NewSignatureBytes))
else if (magic.StartsWith(Data.Models.RAR.Constants.NewSignatureBytes))
{
builder.AppendLine($"{padding}Data: [Embedded RAR5 file]"); // TODO: Parse this out and print separately
}
@@ -1385,7 +1390,7 @@ namespace SabreTools.Data.Printers
}
}
private static void PrintResourceRT_MESSAGETABLE(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_MESSAGETABLE(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
@@ -1452,19 +1457,19 @@ namespace SabreTools.Data.Printers
}
}
private static void PrintResourceRT_GROUP_CURSOR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_GROUP_CURSOR(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Hardware-independent cursor resource found, not parsed yet");
}
private static void PrintResourceRT_GROUP_ICON(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_GROUP_ICON(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Hardware-independent icon resource found, not parsed yet");
}
private static void PrintResourceRT_VERSION(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_VERSION(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
@@ -1585,37 +1590,37 @@ namespace SabreTools.Data.Printers
}
}
private static void PrintResourceRT_DLGINCLUDE(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_DLGINCLUDE(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}External header resource found, not parsed yet");
}
private static void PrintResourceRT_PLUGPLAY(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_PLUGPLAY(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Plug and Play resource found, not parsed yet");
}
private static void PrintResourceRT_VXD(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_VXD(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}VXD found, not parsed yet");
}
private static void PrintResourceRT_ANICURSOR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_ANICURSOR(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Animated cursor found, not parsed yet");
}
private static void PrintResourceRT_ANIICON(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_ANIICON(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}Animated icon found, not parsed yet");
}
private static void PrintResourceRT_HTML(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_HTML(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
builder.AppendLine($"{padding}HTML resource found, not parsed yet");
@@ -1628,7 +1633,7 @@ namespace SabreTools.Data.Printers
// builder.AppendLine(Encoding.Unicode.GetString(entry.Data), $"{padding}Value (Unicode)");
}
private static void PrintResourceRT_MANIFEST(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
private static void PrintResourceRT_MANIFEST(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
@@ -1805,7 +1810,7 @@ namespace SabreTools.Data.Printers
}
}
private static void PrintResourceUNKNOWN(Models.PortableExecutable.Resource.DataEntry entry, int level, object resourceType, StringBuilder builder)
private static void PrintResourceUNKNOWN(Data.Models.PortableExecutable.Resource.DataEntry entry, int level, object resourceType, StringBuilder builder)
{
string padding = new(' ', (level + 1) * 2);
@@ -1847,11 +1852,11 @@ namespace SabreTools.Data.Printers
{
builder.AppendLine($"{padding}Data: [Embedded spanned PKZIP file]"); // TODO: Parse this out and print separately
}
else if (magic.StartsWith(Models.RAR.Constants.OldSignatureBytes))
else if (magic.StartsWith(Data.Models.RAR.Constants.OldSignatureBytes))
{
builder.AppendLine($"{padding}Data: [Embedded RAR file]"); // TODO: Parse this out and print separately
}
else if (magic.StartsWith(Models.RAR.Constants.NewSignatureBytes))
else if (magic.StartsWith(Data.Models.RAR.Constants.NewSignatureBytes))
{
builder.AppendLine($"{padding}Data: [Embedded RAR5 file]"); // TODO: Parse this out and print separately
}

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.Quantum;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class Quantum : IPrinter<Archive>
public partial class Quantum : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive archive)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive archive)
{
builder.AppendLine("Quantum Information:");
builder.AppendLine("-------------------------");

View File

@@ -77,14 +77,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => throw new System.NotImplementedException();
#endif
#endregion
}
}

View File

@@ -77,14 +77,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => throw new System.NotImplementedException();
#endif
#endregion
}
}

View File

@@ -77,14 +77,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => throw new System.NotImplementedException();
#endif
#endregion
}
}

View File

@@ -0,0 +1,92 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.StarForce;
namespace SabreTools.Serialization.Wrappers
{
public partial class SFFS : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, FileSystem fs)
{
builder.AppendLine("StarForce File System Information:");
builder.AppendLine("-------------------------");
builder.AppendLine();
Print(builder, fs.Header);
Print(builder, fs.Files);
Print(builder, fs.FileHeaders);
}
private static void Print(StringBuilder builder, Header? header)
{
builder.AppendLine(" Header Information:");
builder.AppendLine(" -------------------------");
if (header == null)
{
builder.AppendLine(" No header");
builder.AppendLine();
return;
}
builder.AppendLine(header.Magic, " Magic");
builder.AppendLine(header.Version, " Version");
builder.AppendLine(header.FileCount, " FileCount");
builder.AppendLine();
}
private static void Print(StringBuilder builder, FileEntry[]? entries)
{
builder.AppendLine(" File Entries Information:");
builder.AppendLine(" -------------------------");
if (entries == null || entries.Length == 0)
{
builder.AppendLine(" No file entries");
builder.AppendLine();
return;
}
for (int i = 0; i < entries.Length; i++)
{
var file = entries[i];
builder.AppendLine($" File {i}");
builder.AppendLine(file.FilenameMD5Hash, " Filename MD5 hash");
builder.AppendLine(file.FileHeaderIndex, " File header index");
}
builder.AppendLine();
}
private static void Print(StringBuilder builder, FileHeader[]? entries)
{
builder.AppendLine(" File Headers Information:");
builder.AppendLine(" -------------------------");
if (entries == null || entries.Length == 0)
{
builder.AppendLine(" No file headers");
builder.AppendLine();
return;
}
for (int i = 0; i < entries.Length; i++)
{
var file = entries[i];
builder.AppendLine($" File {i}");
builder.AppendLine(file.FileContentStart, " File content start");
builder.AppendLine(file.FileInfo, " File info");
}
builder.AppendLine();
}
}
}

View File

@@ -9,7 +9,7 @@ namespace SabreTools.Serialization.Wrappers
/// types that typically do not have models.
/// </summary>
/// TODO: Hook up the models to a proper deserializer
public class SFFS : WrapperBase<FileSystem>
public partial class SFFS : WrapperBase<FileSystem>
{
#region Descriptive Properties
@@ -78,14 +78,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => throw new System.NotImplementedException();
#endif
#endregion
}
}

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.SGA;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class SGA : IPrinter<Archive>
public partial class SGA : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive file)
{
builder.AppendLine("SGA Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.SecuROM;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class SecuROMDFA : IPrinter<DFAFile>
public partial class SecuROMDFA : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, DFAFile model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, DFAFile dfaFile)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, DFAFile dfaFile)
{
builder.AppendLine("SecuROM DFA File Information:");
builder.AppendLine("-------------------------");

View File

@@ -3,7 +3,7 @@ using SabreTools.Data.Models.SecuROM;
namespace SabreTools.Serialization.Wrappers
{
public class SecuROMDFA : WrapperBase<DFAFile>
public partial class SecuROMDFA : WrapperBase<DFAFile>
{
#region Descriptive Properties

View File

@@ -0,0 +1,66 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.SecuROM;
namespace SabreTools.Serialization.Wrappers
{
public partial class SecuROMMatroschkaPackage : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, MatroshkaPackage package)
{
builder.AppendLine("SecuROM Matroschka Package Information:");
builder.AppendLine("-------------------------");
builder.AppendLine();
builder.AppendLine(package.Signature, "Signature");
builder.AppendLine(package.EntryCount, "Entry count");
builder.AppendLine(package.UnknownRCValue1, "Unknown RC value 1");
builder.AppendLine(package.UnknownRCValue2, "Unknown RC value 2");
builder.AppendLine(package.UnknownRCValue3, "Unknown RC value 3");
builder.AppendLine(package.KeyHexString, "Key hex string");
builder.AppendLine(package.Padding, "Padding");
builder.AppendLine();
Print(builder, package.Entries);
}
private static void Print(StringBuilder builder, MatroshkaEntry[]? entries)
{
builder.AppendLine(" Entries Information:");
builder.AppendLine(" -------------------------");
if (entries == null || entries.Length == 0)
{
builder.AppendLine(" No entries");
builder.AppendLine();
return;
}
for (int i = 0; i < entries.Length; i++)
{
var file = entries[i];
builder.AppendLine($" File {i}");
builder.AppendLine(file.Path, " Path");
builder.AppendLine($"Entry type: {file.EntryType} (0x{(uint)file.EntryType:X8})");
builder.AppendLine(file.Size, " Size");
builder.AppendLine(file.Offset, " Offset");
builder.AppendLine(file.Unknown, " Unknown");
builder.AppendLine(file.ModifiedTime, " Modified time");
builder.AppendLine(file.CreatedTime, " Created time");
builder.AppendLine(file.AccessedTime, " Accessed time");
builder.AppendLine(file.MD5, " MD5");
// builder.AppendLine(file.FileData, " File data");
}
builder.AppendLine();
}
}
}

View File

@@ -77,14 +77,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => throw new System.NotImplementedException();
#endif
#endregion
}
}

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.TAR;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class TapeArchive : IPrinter<Archive>
public partial class TapeArchive : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive file)
{
builder.AppendLine("Tape Archive Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.BSP;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class VBSP : IPrinter<VbspFile>
public partial class VBSP : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, VbspFile model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, VbspFile file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, VbspFile file)
{
builder.AppendLine("BSP Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.VPK;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class VPK : IPrinter<File>
public partial class VPK : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, File model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, File file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, File file)
{
builder.AppendLine("VPK Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.WAD3;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class WAD3 : IPrinter<File>
public partial class WAD3 : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, File model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, File file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, File file)
{
builder.AppendLine("WAD Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.WiseInstaller;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class WiseOverlayHeader : IPrinter<OverlayHeader>
public partial class WiseOverlayHeader : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, OverlayHeader model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, OverlayHeader overlayHeader)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, OverlayHeader overlayHeader)
{
#if NET20 || NET35
bool pkzip = (overlayHeader.Flags & OverlayHeaderFlags.WISE_FLAG_PK_ZIP) != 0;
@@ -22,7 +28,7 @@ namespace SabreTools.Data.Printers
builder.AppendLine(overlayHeader.DllNameLen, "DLL name length");
builder.AppendLine(overlayHeader.DllName, "DLL name");
builder.AppendLine(overlayHeader.DllSize, "DLL size");
builder.AppendLine($"Flags: {overlayHeader.Flags} (0x{(uint)overlayHeader.Flags:X4})");
builder.AppendLine($"Flags: {overlayHeader.Flags} (0x{(uint)overlayHeader.Flags:X8})");
builder.AppendLine(pkzip, " Uses PKZIP containers");
builder.AppendLine(overlayHeader.GraphicsData, "Graphics data");
builder.AppendLine(overlayHeader.WiseScriptExitEventOffset, "Wise script exit event offset");
@@ -45,13 +51,13 @@ namespace SabreTools.Data.Printers
builder.AppendLine(overlayHeader.DibInflatedSize, "DIB inflated size");
builder.AppendLine(overlayHeader.InstallScriptDeflatedSize, "Install script deflated size");
if (overlayHeader.CharacterSet != null)
builder.AppendLine($"Character set: {overlayHeader.CharacterSet} (0x{(uint)overlayHeader.CharacterSet:X4})");
builder.AppendLine($"Character set: {overlayHeader.CharacterSet} (0x{(uint)overlayHeader.CharacterSet:X8})");
else
builder.AppendLine((uint?)null, $"Character set");
builder.AppendLine($"Endianness: {overlayHeader.Endianness} (0x{(uint)overlayHeader.Endianness:X4})");
builder.AppendLine($"Endianness: {overlayHeader.Endianness} (0x{(ushort)overlayHeader.Endianness:X4})");
builder.AppendLine(overlayHeader.InitTextLen, "Init text length");
builder.AppendLine(overlayHeader.InitText, "Init text");
builder.AppendLine();
}
}
}
}

View File

@@ -3,15 +3,20 @@ using SabreTools.Data.Extensions;
using SabreTools.Data.Models.WiseInstaller;
using SabreTools.Data.Models.WiseInstaller.Actions;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class WiseScript : IPrinter<ScriptFile>
public partial class WiseScript : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, ScriptFile model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, ScriptFile scriptFile)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, ScriptFile scriptFile)
{
builder.AppendLine("Wise Installer Script File Information:");
builder.AppendLine("-------------------------");
@@ -836,4 +841,4 @@ namespace SabreTools.Data.Printers
#endregion
}
}
}

View File

@@ -10,7 +10,7 @@ using SabreTools.IO.Extensions;
namespace SabreTools.Serialization.Wrappers
{
public class WiseScript : WrapperBase<ScriptFile>
public partial class WiseScript : WrapperBase<ScriptFile>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.WiseInstaller;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class WiseSectionHeader : IPrinter<SectionHeader>
public partial class WiseSectionHeader : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, SectionHeader model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, SectionHeader header)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, SectionHeader header)
{
builder.AppendLine("Wise Section Header Information:");
builder.AppendLine("-------------------------");
@@ -56,4 +62,4 @@ namespace SabreTools.Data.Printers
builder.AppendLine();
}
}
}
}

View File

@@ -58,7 +58,7 @@ namespace SabreTools.Serialization.Wrappers
#endif
/// <summary>
/// Lock for accessing <see cref="_dataSource"/>
/// Lock for accessing <see cref="_dataSource"/>
/// </summary>
protected readonly object _dataSourceLock = new();
@@ -157,7 +157,7 @@ namespace SabreTools.Serialization.Wrappers
/// This method locks the data source to avoid potential conflicts in reading
/// from the data source. This should be the preferred way of reading in cases
/// where there may be multiple threads accessing the wrapper.
///
///
/// This method will return an empty array if the length is greater than what is left
/// in the stream. This is different behavior than a normal stream read that would
/// attempt to read as much as possible, returning the amount of bytes read.
@@ -171,16 +171,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <summary>
/// Export the item information as JSON
/// </summary>
public abstract string ExportJSON();
#endif
#endregion
}
}

View File

@@ -92,14 +92,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
#endregion
}
}

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using static SabreTools.Data.Models.Xbox.Constants;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class XMID : IPrinter<Models.Xbox.XMID>
public partial class XMID : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Models.Xbox.XMID model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Models.Xbox.XMID xmid)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Data.Models.Xbox.XMID xmid)
{
builder.AppendLine("Xbox Media Identifier Information:");
builder.AppendLine("-------------------------");

View File

@@ -4,7 +4,7 @@ using static SabreTools.Data.Models.Xbox.Constants;
namespace SabreTools.Serialization.Wrappers
{
public class XMID : WrapperBase<Data.Models.Xbox.XMID>
public partial class XMID : WrapperBase<Data.Models.Xbox.XMID>
{
#region Descriptive Properties

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.XZ;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class XZ : IPrinter<Archive>
public partial class XZ : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Archive model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Archive archive)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Archive archive)
{
builder.AppendLine("xz Information:");
builder.AppendLine("-------------------------");

View File

@@ -91,14 +91,5 @@ namespace SabreTools.Serialization.Wrappers
}
#endregion
#region JSON Export
#if NETCOREAPP
/// <inheritdoc/>
public override string ExportJSON() => throw new System.NotImplementedException();
#endif
#endregion
}
}

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using SabreTools.Data.Models.XZP;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class XZP : IPrinter<File>
public partial class XZP : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, File model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, File file)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, File file)
{
builder.AppendLine("XZP Information:");
builder.AppendLine("-------------------------");

View File

@@ -1,15 +1,21 @@
using System.Text;
using SabreTools.Data.Extensions;
using static SabreTools.Data.Models.Xbox.Constants;
namespace SabreTools.Data.Printers
namespace SabreTools.Serialization.Wrappers
{
public class XeMID : IPrinter<Models.Xbox.XeMID>
public partial class XeMID : IPrintable
{
#if NETCOREAPP
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder, Models.Xbox.XeMID model)
=> Print(builder, model);
public string ExportJSON() => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#endif
public static void Print(StringBuilder builder, Models.Xbox.XeMID xemid)
/// <inheritdoc/>
public void PrintInformation(StringBuilder builder)
=> Print(builder, Model);
private static void Print(StringBuilder builder, Data.Models.Xbox.XeMID xemid)
{
builder.AppendLine("Xbox Media Identifier Information:");
builder.AppendLine("-------------------------");

View File

@@ -4,7 +4,7 @@ using static SabreTools.Data.Models.Xbox.Constants;
namespace SabreTools.Serialization.Wrappers
{
public class XeMID : WrapperBase<Data.Models.Xbox.XeMID>
public partial class XeMID : WrapperBase<Data.Models.Xbox.XeMID>
{
#region Descriptive Properties