Compare commits

..

40 Commits
1.4.2 ... 1.5.0

Author SHA1 Message Date
Matt Nadareski
006ced0430 Bump version 2024-04-04 12:00:53 -04:00
Matt Nadareski
bee6c0ba11 Add byte deserializers for remaining stream deserializers 2024-04-03 23:25:54 -04:00
Matt Nadareski
3cb880ff3f Update SabreTools.Models 2024-04-03 22:54:30 -04:00
Matt Nadareski
f1d54e4a14 Add XML byte deserialization 2024-04-03 22:41:49 -04:00
Matt Nadareski
f4aaed7f9c Move overlay extension method 2024-04-03 22:31:24 -04:00
Matt Nadareski
46ad76c5d2 Add flag for long/short SeparatedValue writing 2024-04-03 22:26:23 -04:00
Matt Nadareski
8f731cebc8 Add array constants for AttractMode 2024-04-03 22:21:39 -04:00
Matt Nadareski
6dbf9dacd6 Add flag for long/short AttractMode writing 2024-04-03 22:18:05 -04:00
Matt Nadareski
94ab760c67 Remove unnecessary code 2024-04-03 21:57:14 -04:00
Matt Nadareski
4ed3880bad Use SabreTools.Hashing for hash types 2024-04-03 21:56:21 -04:00
Matt Nadareski
ff8dcd30a5 Move some constants to the deserializer 2024-04-03 21:46:35 -04:00
Matt Nadareski
8ced91d0fa Move some constants to the deserializer 2024-04-03 21:44:02 -04:00
Matt Nadareski
f2c6fa2b8e Convert string serialization to new framework 2024-04-03 21:42:08 -04:00
Matt Nadareski
9b1bacd167 Move serializers to new organization 2024-04-03 21:27:50 -04:00
Matt Nadareski
964c97200c Move stream deserializers to new organization 2024-04-03 20:55:02 -04:00
Matt Nadareski
a3f3384ac9 Move file deserializers to new organization 2024-04-03 17:27:08 -04:00
Matt Nadareski
8b546fbf27 Start splitting serialziation differently for clarity 2024-04-03 16:41:54 -04:00
Matt Nadareski
15da711087 Rename IByteSerializer to IByteDeserializer 2024-04-03 16:37:26 -04:00
Matt Nadareski
bfee7dd449 Use better naming 2024-04-03 16:35:54 -04:00
Matt Nadareski
9de2a91e80 Fix inheritdoc 2024-04-03 16:15:48 -04:00
Matt Nadareski
bf50c801b2 Simplify some static deserializers 2024-04-03 16:00:18 -04:00
Matt Nadareski
c19a4a94f4 Use new static stream serializer 2024-04-03 15:50:06 -04:00
Matt Nadareski
b6fe94116b Add static serializers for IStreamSerializer 2024-04-03 15:43:36 -04:00
Matt Nadareski
bcf604c773 Use new static stream deserializer 2024-04-03 15:23:49 -04:00
Matt Nadareski
74984a9114 Add static deserializers for IStreamSerializer 2024-04-03 15:22:35 -04:00
Matt Nadareski
8c1e241286 Add static serializers for IFileSerializer 2024-04-03 14:58:06 -04:00
Matt Nadareski
f666d737cb Add static deserializers for IFileSerializer 2024-04-03 14:28:47 -04:00
Matt Nadareski
a01609f1d1 Add static serializers for IByteSerializer 2024-04-03 14:06:23 -04:00
Matt Nadareski
8ca9ccaf00 Handle invalid texture counts 2024-04-02 16:55:43 -04:00
Matt Nadareski
fc5374108c Bump version 2024-04-02 16:15:29 -04:00
Matt Nadareski
15452ded52 Use new IO extension 2024-04-02 16:12:08 -04:00
Matt Nadareski
49c6c4412b Update SabreTools.IO 2024-04-02 16:10:58 -04:00
Matt Nadareski
cfc53f66a8 Fix cuesheet serialization 2024-04-02 15:30:43 -04:00
Matt Nadareski
ec1fb7247c Add file serializers for all stream variants 2024-04-02 14:28:30 -04:00
Matt Nadareski
54b1eef8ae Better handle version 3 CFB files, probably (fixes #3) 2024-04-02 12:54:54 -04:00
Matt Nadareski
f448314309 Add file serializer for CFB 2024-04-02 12:45:31 -04:00
Matt Nadareski
c4e8debb15 Detect invalid dialog item counts (fixes #5) 2024-04-02 12:35:14 -04:00
Matt Nadareski
822839c813 Add file serializers for executable types 2024-04-02 12:06:56 -04:00
Matt Nadareski
27d36a11ca Add skeleton test executable 2024-04-02 11:56:27 -04:00
Matt Nadareski
92d9ca932d Move library code to subfolder 2024-04-02 11:51:39 -04:00
278 changed files with 4559 additions and 2873 deletions

View File

@@ -28,13 +28,13 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: 'Nuget Package'
path: 'bin/Release/*.nupkg'
path: 'SabreTools.Serialization/bin/Release/*.nupkg'
- name: Upload to rolling
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: True
artifacts: 'bin/Release/*.nupkg'
artifacts: 'SabreTools.Serialization/bin/Release/*.nupkg'
body: 'Last built commit: ${{ github.sha }}'
name: 'Rolling Release'
prerelease: True

View File

@@ -1,14 +0,0 @@
namespace SabreTools.Serialization
{
/// <summary>
/// Separated value serializer/deserializer for AttractMode romlists
/// </summary>
public static class AttractMode
{
public const string HeaderWithoutRomname = "#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons";
public const int HeaderWithoutRomnameCount = 17;
public const string HeaderWithRomname = "#Romname;Title;Emulator;Cloneof;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons;Favourite;Tags;PlayedCount;PlayedTime;FileIsAvailable";
public const int HeaderWithRomnameCount = 22;
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.AACS;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class AACS : IByteSerializer<MediaKeyBlock>
{
/// <inheritdoc/>
public MediaKeyBlock? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.AACS().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.BDPlus;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class BDPlus : IByteSerializer<SVM>
{
/// <inheritdoc/>
public SVM? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.BDPlus().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.BFPK;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class BFPK : IByteSerializer<Archive>
{
/// <inheritdoc/>
public Archive? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.BFPK().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class BSP : IByteSerializer<Models.BSP.File>
{
/// <inheritdoc/>
public Models.BSP.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.BSP().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.CFB;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class CFB : IByteSerializer<Binary>
{
/// <inheritdoc/>
public Binary? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.CFB().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class CIA : IByteSerializer<Models.N3DS.CIA>
{
/// <inheritdoc/>
public Models.N3DS.CIA? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.CIA().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class GCF : IByteSerializer<Models.GCF.File>
{
/// <inheritdoc/>
public Models.GCF.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.GCF().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class IRD : IByteSerializer<Models.IRD.File>
{
/// <inheritdoc/>
public Models.IRD.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.IRD().Deserialize(dataStream);
}
}
}

View File

@@ -1,26 +0,0 @@
using System.IO;
using SabreTools.Models.InstallShieldCabinet;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
// TODO: Add multi-cabinet reading
public partial class InstallShieldCabinet : IByteSerializer<Cabinet>
{
/// <inheritdoc/>
public Cabinet? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.InstallShieldCabinet().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.LinearExecutable;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class LinearExecutable : IByteSerializer<Executable>
{
/// <inheritdoc/>
public Executable? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.LinearExecutable().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.MSDOS;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class MSDOS : IByteSerializer<Executable>
{
/// <inheritdoc/>
public Executable? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.MSDOS().Deserialize(dataStream);
}
}
}

View File

@@ -1,26 +0,0 @@
using System.IO;
using SabreTools.Models.MicrosoftCabinet;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
// TODO: Add multi-cabinet reading
public partial class MicrosoftCabinet : IByteSerializer<Cabinet>
{
/// <inheritdoc/>
public Cabinet? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.MicrosoftCabinet().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.MoPaQ;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class MoPaQ : IByteSerializer<Archive>
{
/// <inheritdoc/>
public Archive? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.MoPaQ().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.N3DS;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class N3DS : IByteSerializer<Cart>
{
/// <inheritdoc/>
public Cart? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.N3DS().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class NCF : IByteSerializer<Models.NCF.File>
{
/// <inheritdoc/>
public Models.NCF.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.NCF().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.NewExecutable;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class NewExecutable : IByteSerializer<Executable>
{
/// <inheritdoc/>
public Executable? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.NewExecutable().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.Nitro;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class Nitro : IByteSerializer<Cart>
{
/// <inheritdoc/>
public Cart? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.Nitro().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class PAK : IByteSerializer<Models.PAK.File>
{
/// <inheritdoc/>
public Models.PAK.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.PAK().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.PFF;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class PFF : IByteSerializer<Archive>
{
/// <inheritdoc/>
public Archive? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.PFF().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.PlayJ;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class PlayJAudio : IByteSerializer<AudioFile>
{
/// <inheritdoc/>
public AudioFile? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.PlayJAudio().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.PlayJ;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class PlayJPlaylist : IByteSerializer<Playlist>
{
/// <inheritdoc/>
public Playlist? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.PlayJPlaylist().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.PortableExecutable;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class PortableExecutable : IByteSerializer<Executable>
{
/// <inheritdoc/>
public Executable? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.PortableExecutable().Deserialize(dataStream);
}
}
}

View File

@@ -1,25 +0,0 @@
using System.IO;
using SabreTools.Models.Quantum;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class Quantum : IByteSerializer<Archive>
{
/// <inheritdoc/>
public Archive? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.Quantum().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class SGA : IByteSerializer<Models.SGA.File>
{
/// <inheritdoc/>
public Models.SGA.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.SGA().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class VBSP : IByteSerializer<Models.VBSP.File>
{
/// <inheritdoc/>
public Models.VBSP.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.VBSP().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class VPK : IByteSerializer<Models.VPK.File>
{
/// <inheritdoc/>
public Models.VPK.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.VPK().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class WAD : IByteSerializer<Models.WAD.File>
{
/// <inheritdoc/>
public Models.WAD.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.WAD().Deserialize(dataStream);
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Bytes
{
public partial class XZP : IByteSerializer<Models.XZP.File>
{
/// <inheritdoc/>
public Models.XZP.File? Deserialize(byte[]? data, int offset)
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.XZP().Deserialize(dataStream);
}
}
}

View File

@@ -1,13 +0,0 @@
namespace SabreTools.Serialization
{
public enum Hash
{
CRC,
MD5,
SHA1,
SHA256,
SHA384,
SHA512,
SpamSum,
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class ArchiveDotOrg : XmlFile<Models.ArchiveDotOrg.Files>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class ArchiveDotOrg : XmlFile<Models.ArchiveDotOrg.Files>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,17 +0,0 @@
using SabreTools.Models.AttractMode;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class AttractMode : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.AttractMode().Deserialize(stream);
}
}
}
}

View File

@@ -1,24 +0,0 @@
using System.IO;
using SabreTools.Models.AttractMode;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class AttractMode : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public bool Serialize(MetadataFile? obj, string? path)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.AttractMode().Serialize(obj);
if (stream == null)
return false;
using var fs = File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,11 +0,0 @@
using System.Text;
namespace SabreTools.Serialization.Files
{
public partial class Catalog : JsonFile<Models.Xbox.Catalog>
{
// Catalog.js file is a UTF-16 LE JSON
public new Models.Xbox.Catalog? Deserialize(string? path)
=> Deserialize(path, new UnicodeEncoding());
}
}

View File

@@ -1,11 +0,0 @@
using System.Text;
namespace SabreTools.Serialization.Files
{
public partial class Catalog : JsonFile<Models.Xbox.Catalog>
{
// Catalog.js file is a UTF-16 LE JSON
public new bool Serialize(Models.Xbox.Catalog? obj, string? path)
=> Serialize(obj, path, new UnicodeEncoding());
}
}

View File

@@ -1,20 +0,0 @@
using SabreTools.Models.ClrMamePro;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class ClrMamePro : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path) => Deserialize(path, true);
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path, bool quotes)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.ClrMamePro().Deserialize(stream, quotes);
}
}
}
}

View File

@@ -1,27 +0,0 @@
using System.IO;
using SabreTools.Models.ClrMamePro;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class ClrMamePro : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public bool Serialize(MetadataFile? obj, string? path) => Serialize(obj, path, true);
/// <inheritdoc cref="Serialize(MetadataFile, string)"/>
public bool Serialize(MetadataFile? obj, string? path, bool quotes)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.ClrMamePro().Serialize(obj, quotes);
if (stream == null)
return false;
using var fs = File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,23 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class CueSheet : IFileSerializer<Models.CueSheets.CueSheet>
{
/// <inheritdoc/>
public bool Serialize(Models.CueSheets.CueSheet? obj, string? path)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.CueSheet().Serialize(obj);
if (stream == null)
return false;
using var fs = File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,17 +0,0 @@
using SabreTools.Models.DosCenter;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class DosCenter : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.DosCenter().Deserialize(stream);
}
}
}
}

View File

@@ -1,23 +0,0 @@
using SabreTools.Models.DosCenter;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class DosCenter : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public bool Serialize(MetadataFile? obj, string? path)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.DosCenter().Serialize(obj);
if (stream == null)
return false;
using var fs = System.IO.File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,17 +0,0 @@
using SabreTools.Models.EverdriveSMDB;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class EverdriveSMDB : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.EverdriveSMDB().Deserialize(stream);
}
}
}
}

View File

@@ -1,23 +0,0 @@
using SabreTools.Models.EverdriveSMDB;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class EverdriveSMDB : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public bool Serialize(MetadataFile? obj, string? path)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.EverdriveSMDB().Serialize(obj);
if (stream == null)
return false;
using var fs = System.IO.File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,19 +0,0 @@
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class Hashfile : IFileSerializer<Models.Hashfile.Hashfile>
{
/// <inheritdoc/>
public Models.Hashfile.Hashfile? Deserialize(string? path) => Deserialize(path, Hash.CRC);
/// <inheritdoc/>
public Models.Hashfile.Hashfile? Deserialize(string? path, Hash hash)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.Hashfile().Deserialize(stream, hash);
}
}
}
}

View File

@@ -1,25 +0,0 @@
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class Hashfile : IFileSerializer<Models.Hashfile.Hashfile>
{
/// <inheritdoc/>
public bool Serialize(Models.Hashfile.Hashfile? obj, string? path) => Serialize(obj, path, Hash.CRC);
/// <inheritdoc/>
public bool Serialize(Models.Hashfile.Hashfile? obj, string? path, Hash hash)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.Hashfile().Serialize(obj, hash);
if (stream == null)
return false;
using var fs = System.IO.File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,16 +0,0 @@
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class IRD : IFileSerializer<Models.IRD.File>
{
/// <inheritdoc/>
public Models.IRD.File? Deserialize(string? path)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.IRD().Deserialize(stream);
}
}
}
}

View File

@@ -1,22 +0,0 @@
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class IRD : IFileSerializer<Models.IRD.File>
{
/// <inheritdoc/>
public bool Serialize(Models.IRD.File? obj, string? path)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.IRD().Serialize(obj);
if (stream == null)
return false;
using var fs = System.IO.File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,31 +0,0 @@
using System.Text;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
/// <summary>
/// Base class for other JSON serializers
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class JsonFile<T> : IFileSerializer<T>
{
/// <inheritdoc/>
public T? Deserialize(string? path)
=> Deserialize(path, new UTF8Encoding(false));
/// <summary>
/// Deserialize a file into <typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">Type of object to deserialize to</typeparam>
/// <param name="path">Path to deserialize from</param>
/// <param name="encoding">Encoding to parse text as</param>
/// <returns>Filled object on success, null on error</returns>
public T? Deserialize(string? path, Encoding encoding)
{
using (var data = PathProcessor.OpenStream(path))
{
return new Streams.JsonFile<T>().Deserialize(data, encoding);
}
}
}
}

View File

@@ -1,40 +0,0 @@
using System.IO;
using System.Text;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
/// <summary>
/// Base class for other JSON serializers
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class JsonFile<T> : IFileSerializer<T>
{
/// <inheritdoc/>
public bool Serialize(T? obj, string? path)
=> Serialize(obj, path, new UTF8Encoding(false));
/// <summary>
/// Serialize a <typeparamref name="T"/> into a file
/// </summary>
/// <typeparam name="T">Type of object to serialize from</typeparam>
/// <param name="obj">Data to serialize</param>
/// <param name="path">Path to the file to serialize to</param>
/// <param name="encoding">Encoding to parse text as</param>
/// <returns>True on successful serialization, false otherwise</returns>
public bool Serialize(T? obj, string? path, Encoding encoding)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.JsonFile<T>().Serialize(obj, encoding);
if (stream == null)
return false;
using var fs = File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,17 +0,0 @@
using SabreTools.Models.Listrom;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class Listrom : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.Listrom().Deserialize(stream);
}
}
}
}

View File

@@ -1,23 +0,0 @@
using SabreTools.Models.Listrom;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class Listrom : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public bool Serialize(MetadataFile? obj, string? path)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.Listrom().Serialize(obj);
if (stream == null)
return false;
using var fs = System.IO.File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class Listxml : XmlFile<Models.Listxml.Mame>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class Listxml : XmlFile<Models.Listxml.Mame>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class Logiqx : XmlFile<Models.Logiqx.Datafile>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,11 +0,0 @@
using SabreTools.Models.Logiqx;
namespace SabreTools.Serialization.Files
{
public partial class Logiqx : XmlFile<Datafile>
{
/// <inheritdoc cref="Serialize(Datafile, string, string?, string?, string?, string?)" />
public bool SerializeToFileWithDocType(Datafile? obj, string path)
=> Serialize(obj, path, Serialization.Logiqx.DocTypeName, Serialization.Logiqx.DocTypePubId, Serialization.Logiqx.DocTypeSysId, Serialization.Logiqx.DocTypeSysId);
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class M1 : XmlFile<Models.Listxml.M1>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class M1 : XmlFile<Models.Listxml.M1>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class OfflineList : XmlFile<Models.OfflineList.Dat>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class OfflineList : XmlFile<Models.OfflineList.Dat>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class OpenMSX : XmlFile<Models.OpenMSX.SoftwareDb>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,11 +0,0 @@
using SabreTools.Models.OpenMSX;
namespace SabreTools.Serialization.Files
{
public partial class OpenMSX : XmlFile<SoftwareDb>
{
/// <inheritdoc cref="Serialize(SoftwareDb, string, string?, string?, string?, string?)" />
public bool SerializeToFileWithDocType(SoftwareDb? obj, string path)
=> Serialize(obj, path, Serialization.OpenMSX.DocTypeName, Serialization.OpenMSX.DocTypePubId, Serialization.OpenMSX.DocTypeSysId, Serialization.OpenMSX.DocTypeSysId);
}
}

View File

@@ -1,17 +0,0 @@
using SabreTools.Models.PIC;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class PIC : IFileSerializer<DiscInformation>
{
/// <inheritdoc/>
public DiscInformation? Deserialize(string? path)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.PIC().Deserialize(stream);
}
}
}
}

View File

@@ -1,23 +0,0 @@
using SabreTools.Models.PIC;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class PIC : IFileSerializer<DiscInformation>
{
/// <inheritdoc/>
public bool Serialize(DiscInformation? obj, string? path)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.PIC().Serialize(obj);
if (stream == null)
return false;
using var fs = System.IO.File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,17 +0,0 @@
using SabreTools.Models.RomCenter;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class RomCenter : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.RomCenter().Deserialize(stream);
}
}
}
}

View File

@@ -1,23 +0,0 @@
using SabreTools.Models.RomCenter;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class RomCenter : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public bool Serialize(MetadataFile? obj, string? path)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.RomCenter().Serialize(obj);
if (stream == null)
return false;
using var fs = System.IO.File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,20 +0,0 @@
using SabreTools.Models.SeparatedValue;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class SeparatedValue : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path) => Deserialize(path, ',');
/// <inheritdoc/>
public MetadataFile? Deserialize(string? path, char delim)
{
using (var stream = PathProcessor.OpenStream(path))
{
return new Streams.SeparatedValue().Deserialize(stream, delim);
}
}
}
}

View File

@@ -1,26 +0,0 @@
using SabreTools.Models.SeparatedValue;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
public partial class SeparatedValue : IFileSerializer<MetadataFile>
{
/// <inheritdoc/>
public bool Serialize(MetadataFile? obj, string? path) => Serialize(obj, path, ',');
/// <inheritdoc/>
public bool Serialize(MetadataFile? obj, string? path, char delim)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.SeparatedValue().Serialize(obj, delim);
if (stream == null)
return false;
using var fs = System.IO.File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,7 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class SoftwareList : XmlFile<Models.SoftwareList.SoftwareList>
{
// All serialization logic is in the base class
}
}

View File

@@ -1,9 +0,0 @@
namespace SabreTools.Serialization.Files
{
public partial class SoftwareList : XmlFile<Models.SoftwareList.SoftwareList>
{
/// <inheritdoc cref="SerializeToFile(Models.SoftwareList.SoftwareList, string, string?, string?, string?, string?)" />
public bool SerializeToFileWithDocType(Models.SoftwareList.SoftwareList? obj, string path)
=> Serialize(obj, path, Serialization.SoftawreList.DocTypeName, Serialization.SoftawreList.DocTypePubId, Serialization.SoftawreList.DocTypeSysId, Serialization.SoftawreList.DocTypeSysId);
}
}

View File

@@ -1,20 +0,0 @@
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
/// <summary>
/// Base class for other XML serializers
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class XmlFile<T> : IFileSerializer<T>
{
/// <inheritdoc/>
public T? Deserialize(string? path)
{
using (var data = PathProcessor.OpenStream(path))
{
return new Streams.XmlFile<T>().Deserialize(data);
}
}
}
}

View File

@@ -1,41 +0,0 @@
using System.IO;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
/// <summary>
/// Base class for other XML serializers
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class XmlFile<T> : IFileSerializer<T>
{
/// <inheritdoc/>
public bool Serialize(T? obj, string? path)
=> Serialize(obj, path, null, null, null, null);
/// <summary>
/// Serializes the defined type to an XML file
/// </summary>
/// <param name="obj">Data to serialize</param>
/// <param name="path">Path to the file to serialize to</param>
/// <param name="name">Optional DOCTYPE name</param>
/// <param name="pubid">Optional DOCTYPE pubid</param>
/// <param name="sysid">Optional DOCTYPE sysid</param>
/// <param name="subset">Optional DOCTYPE name</param>
/// <returns>True on successful serialization, false otherwise</returns>
public bool Serialize(T? obj, string? path, string? name = null, string? pubid = null, string? sysid = null, string? subset = null)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.XmlFile<T>().Serialize(obj, name, pubid, sysid, subset);
if (stream == null)
return false;
using var fs = File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -1,26 +0,0 @@
using System.IO;
namespace SabreTools.Serialization.Interfaces
{
/// <summary>
/// Defines how to serialize to and from Streams
/// </summary>
public interface IStreamSerializer<T>
{
/// <summary>
/// Deserialize a Stream into <typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">Type of object to deserialize to</typeparam>
/// <param name="data">Stream to parse</param>
/// <returns>Filled object on success, null on error</returns>
T? Deserialize(Stream? data);
/// <summary>
/// Serialize a <typeparamref name="T"/> into a Stream
/// </summary>
/// <typeparam name="T">Type of object to serialize from</typeparam>
/// <param name="obj">Data to serialize</param>
/// <returns>Filled object on success, null on error</returns>
Stream? Serialize(T? obj);
}
}

View File

@@ -1,102 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SabreTools.Models.Metadata;
namespace SabreTools.Serialization
{
public static class Internal
{
/// <summary>
/// Extract nested items from a Dump
/// </summary>
public static DatItem[]? ExtractItems(Dump? item)
{
if (item == null)
return null;
var datItems = new List<DatItem>();
var rom = item.Read<Rom>(Dump.RomKey);
if (rom != null)
datItems.Add(rom);
var megaRom = item.Read<Rom>(Dump.MegaRomKey);
if (megaRom != null)
datItems.Add(megaRom);
var sccPlusCart = item.Read<Rom>(Dump.SCCPlusCartKey);
if (sccPlusCart != null)
datItems.Add(sccPlusCart);
return [.. datItems];
}
/// <summary>
/// Extract nested items from a Part
/// </summary>
public static DatItem[]? ExtractItems(Part? item)
{
if (item == null)
return null;
var datItems = new List<DatItem>();
var features = item.Read<Feature[]>(Part.FeatureKey);
if (features != null && features.Any())
datItems.AddRange(features);
var dataAreas = item.Read<DataArea[]>(Part.DataAreaKey);
if (dataAreas != null && dataAreas.Any())
{
datItems.AddRange(dataAreas
.Where(d => d != null)
.SelectMany(ExtractItems)
.Select(d => d as DatItem));
}
var diskAreas = item.Read<DiskArea[]>(Part.DiskAreaKey);
if (diskAreas != null && diskAreas.Any())
{
datItems.AddRange(diskAreas
.Where(d => d != null)
.SelectMany(ExtractItems)
.Select(d => d as DatItem));
}
var dipSwitches = item.Read<DipSwitch[]>(Part.DipSwitchKey);
if (dipSwitches != null && dipSwitches.Any())
{
datItems.AddRange(dipSwitches
.Where(d => d != null)
.Select(d => d as DatItem));
}
return [.. datItems];
}
/// <summary>
/// Extract nested items from a DataArea
/// </summary>
private static Rom[] ExtractItems(DataArea item)
{
var roms = item.Read<Rom[]>(DataArea.RomKey);
if (roms == null || !roms.Any())
return [];
return [.. roms];
}
/// <summary>
/// Extract nested items from a DiskArea
/// </summary>
private static Disk[] ExtractItems(DiskArea item)
{
var roms = item.Read<Disk[]>(DiskArea.DiskKey);
if (roms == null || !roms.Any())
return [];
return [.. roms];
}
}
}

View File

@@ -1,28 +0,0 @@
namespace SabreTools.Serialization
{
/// <summary>
/// XML deserializer for Logiqx-derived metadata files
/// </summary>
public static class Logiqx
{
/// <summary>
/// name field for DOCTYPE
/// </summary>
public const string DocTypeName = "datafile";
/// <summary>
/// pubid field for DOCTYPE
/// </summary>
public const string DocTypePubId = "-//Logiqx//DTD ROM Management Datafile//EN";
/// <summary>
/// sysid field for DOCTYPE
/// </summary>
public const string DocTypeSysId = "http://www.logiqx.com/Dats/datafile.dtd";
/// <summary>
/// subset field for DOCTYPE
/// </summary>
public const string? DocTypeSubset = null;
}
}

View File

@@ -1,28 +0,0 @@
namespace SabreTools.Serialization
{
/// <summary>
/// XML deserializer for OpenMSX software database files
/// </summary>
public static class OpenMSX
{
/// <summary>
/// name field for DOCTYPE
/// </summary>
public const string DocTypeName = "softwaredb";
/// <summary>
/// pubid field for DOCTYPE
/// </summary>
public const string? DocTypePubId = null;
/// <summary>
/// sysid field for DOCTYPE
/// </summary>
public const string DocTypeSysId = "softwaredb1.dtd";
/// <summary>
/// subset field for DOCTYPE
/// </summary>
public const string? DocTypeSubset = null;
}
}

View File

@@ -4,26 +4,29 @@ This library comprises of serializers that both read and write from files and st
Find the link to the Nuget package [here](https://www.nuget.org/packages/SabreTools.Serialization).
## `SabreTools.Serialization.Bytes`
## Interfaces
This namespace comprises of deserializers that take byte arrays to convert into models.
Below is a table representing the various interfaces that are implemented within this library.
## `SabreTools.Serialization.CrossModel`
| Interface Name | Source Type | Destination Type |
| --- | --- | --- |
| `IByteDeserializer` | `byte[]?` | Model |
| `IFileDeserializer` | `string?` path | Model |
| `IFileSerializer` | Model | `string?` path |
| `IModelSerializer` | Model | Model |
| `IStreamDeserializer` | `Stream?` | Model |
| `IStreamSerializer` | Model | `Stream?` |
| `IStringDeserializer` | `string?` representation | Model |
| `IStringSerializer` | Model | `string?` representation |
| `IWrapper` | N/A | N/A |
This namespace comprises of serializers and deserializers that convert models to other common ones. This is mainly used for metadata files converting to and from a common, `Dictionary`-based model.
## Namespaces
## `SabreTools.Serialization.Files`
Below is a table of all namespaces within the library and what they represent
This namespace comprises of serializers and deserializers that can convert to and from files on disk. Most of the serializers are symmetric, but this is not guaranteed. Unimplemented methods will throw `NotImplementedException`.
## `SabreTools.Serialization.Streams`
This namespace comprises of serializers and deserializers that can convert to and from any type of stream. Most of the serializers are symmetric, but this is not guaranteed. Unimplemented methods will throw `NotImplementedException`.
## `SabreTools.Serialization.Strings`
This namespace comprises of serializers and deserializers that can convert to and from strings. Most of the serializers are symmetric, but this is not guaranteed. Unimplemented methods will throw `NotImplementedException`.
## `SabreTools.Serialization.Wrappers`
This namespace comrpises of wrapping classes that include keeping a reference to the source of each serializable model. Some of the wrappers may also include what are referred to as "extension properties", which are generated properties derived from either parts of the model or the underlying source.
| Namespace | Description |
| --- | --- |
| `SabreTools.Serialization.CrossModel` | Convert between models; mainly used for metadata files converting to and from a common, `Dictionary`-based model |
| `SabreTools.Serialization.Deserializers` | Convert from external sources to models |
| `SabreTools.Serialization.Serializers` | Convert from models to external sources |
| `SabreTools.Serialization.Wrappers` | Classes that wrap serialization and models to allow for including extension properties |

View File

@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Serialization", "SabreTools.Serialization.csproj", "{5B688801-5F36-483E-B2E8-F219BA5923A2}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Serialization", "SabreTools.Serialization\SabreTools.Serialization.csproj", "{5B688801-5F36-483E-B2E8-F219BA5923A2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{F3DEE31A-4726-464C-A90C-C19D78F51898}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -18,5 +20,9 @@ Global
{5B688801-5F36-483E-B2E8-F219BA5923A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B688801-5F36-483E-B2E8-F219BA5923A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B688801-5F36-483E-B2E8-F219BA5923A2}.Release|Any CPU.Build.0 = Release|Any CPU
{F3DEE31A-4726-464C-A90C-C19D78F51898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3DEE31A-4726-464C-A90C-C19D78F51898}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3DEE31A-4726-464C-A90C-C19D78F51898}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3DEE31A-4726-464C-A90C-C19D78F51898}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using SabreTools.Hashing;
using SabreTools.Models.Hashfile;
using SabreTools.Serialization.Interfaces;
@@ -8,10 +9,10 @@ namespace SabreTools.Serialization.CrossModel
public partial class Hashfile : IModelSerializer<Models.Hashfile.Hashfile, Models.Metadata.MetadataFile>
{
/// <inheritdoc/>
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, Hash.CRC);
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, HashType.CRC32);
/// <inheritdoc/>
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj, Hash hash)
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj, HashType hash)
{
if (obj == null)
return null;
@@ -73,7 +74,7 @@ namespace SabreTools.Serialization.CrossModel
/// <summary>
/// Convert from <cref="Models.Metadata.MetadataFile"/> to an array of <cref="Models.Hashfile.Hashfile"/>
/// </summary>
public static Models.Hashfile.Hashfile[]? ConvertArrayFromInternalModel(Models.Metadata.MetadataFile? item, Hash hash)
public static Models.Hashfile.Hashfile[]? ConvertArrayFromInternalModel(Models.Metadata.MetadataFile? item, HashType hash)
{
if (item == null)
return null;
@@ -93,7 +94,7 @@ namespace SabreTools.Serialization.CrossModel
/// <summary>
/// Convert from <cref="Models.Metadata.Machine"/> to <cref="Models.Hashfile.Hashfile"/>
/// </summary>
private static Models.Hashfile.Hashfile ConvertMachineFromInternalModel(Models.Metadata.Machine item, Hash hash)
private static Models.Hashfile.Hashfile ConvertMachineFromInternalModel(Models.Metadata.Machine item, HashType hash)
{
var roms = item.Read<Models.Metadata.Rom[]>(Models.Metadata.Machine.RomKey);
if (roms == null)
@@ -101,43 +102,43 @@ namespace SabreTools.Serialization.CrossModel
return new Models.Hashfile.Hashfile
{
SFV = hash == Hash.CRC
SFV = hash == HashType.CRC32 || hash == HashType.CRC32_ISO || hash == HashType.CRC32_Naive || hash == HashType.CRC32_Optimized || hash == HashType.CRC32_Parallel
? roms
.Where(r => r != null)
.Select(ConvertToSFV)
.ToArray()
: null,
MD5 = hash == Hash.MD5
MD5 = hash == HashType.MD5
? roms
.Where(r => r != null)
.Select(ConvertToMD5)
.ToArray()
: null,
SHA1 = hash == Hash.SHA1
SHA1 = hash == HashType.SHA1
? roms
.Where(r => r != null)
.Select(ConvertToSHA1)
.ToArray()
: null,
SHA256 = hash == Hash.SHA256
SHA256 = hash == HashType.SHA256
? roms
.Where(r => r != null)
.Select(ConvertToSHA256)
.ToArray()
: null,
SHA384 = hash == Hash.SHA384
SHA384 = hash == HashType.SHA384
? roms
.Where(r => r != null)
.Select(ConvertToSHA384)
.ToArray()
: null,
SHA512 = hash == Hash.SHA512
SHA512 = hash == HashType.SHA512
? roms
.Where(r => r != null)
.Select(ConvertToSHA512)
.ToArray()
: null,
SpamSum = hash == Hash.SpamSum
SpamSum = hash == HashType.SpamSum
? roms
.Where(r => r != null)
.Select(ConvertToSpamSum)

Some files were not shown because too many files have changed in this diff Show More