Compare commits

...

78 Commits
1.3.2 ... 1.5.3

Author SHA1 Message Date
Matt Nadareski
c532bd1063 Bump version 2024-04-18 12:16:02 -04:00
Matt Nadareski
e4631a8176 Update SabreTools.IO 2024-04-18 12:04:54 -04:00
Matt Nadareski
ee8dad0c87 Bump version 2024-04-17 13:00:07 -04:00
Matt Nadareski
4163b2f22a Create non-typed variants of IWrapper and WrapperBase 2024-04-17 12:28:08 -04:00
Matt Nadareski
6aaf3afa38 Fix namespace issues 2024-04-17 11:52:22 -04:00
Matt Nadareski
2a7eb44281 Bump version 2024-04-17 11:45:26 -04:00
Matt Nadareski
08bbc93793 Update SabreTools.IO 2024-04-17 11:44:58 -04:00
Matt Nadareski
789478df13 Update SabreTools.IO 2024-04-16 13:16:59 -04:00
Matt Nadareski
cd4f1c9d97 Merge pull request #7 from SabreTools/deserializer-base
Deserializer base
2024-04-04 14:17:57 -04:00
Matt Nadareski
1a2e9fb942 Add PlayJ playlist wrapper 2024-04-04 14:15:27 -04:00
Matt Nadareski
d0865739de Add PIC wrapper 2024-04-04 14:13:03 -04:00
Matt Nadareski
0696bbab72 Add MoPaQ wrapper 2024-04-04 14:06:59 -04:00
Matt Nadareski
4b4c17ac24 Make model type inherent to interface 2024-04-04 14:03:02 -04:00
Matt Nadareski
d768172da1 Update README 2024-04-04 12:03:19 -04:00
Matt Nadareski
2a4d24309d Create base class for serializers 2024-04-04 12:03:19 -04:00
Matt Nadareski
bc01ce4552 Enforce IStreamDeserializer in base class 2024-04-04 12:03:19 -04:00
Matt Nadareski
ef0efe66bd Migrate IFileDeserializer implementation to base class 2024-04-04 12:03:19 -04:00
Matt Nadareski
7c21f65723 Migrate IByteSerializer implementation to base class 2024-04-04 12:03:19 -04:00
Matt Nadareski
cec53e907f Move static deserializers to base class 2024-04-04 12:03:19 -04:00
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
Deterous
69e1f5ff0b De/Serialize XboxOne/XSX catalog.js files (#6)
* Add JSON/catalog.js logic

* Proper json deserialize

* Update packages

* Catalog is UTF-16 LE, make BaseJsonFile encoding independent

* Bump version, use ST.Models 1.4.1

* Implement JsonFile as interface with UTF8 as default

* typo
2024-04-02 08:46:12 -07:00
Matt Nadareski
d265c14841 Bump version 2024-03-25 14:25:28 -04:00
Matt Nadareski
1148245226 Surface NE/LE/PE methods for other library use 2024-03-24 21:09:12 -04:00
Matt Nadareski
f53d9f94e6 Break if StringFileInfo child is total size 0 2024-03-22 23:46:05 -04:00
Matt Nadareski
4e3d832834 Ensure Listrom serializes to the correct model type 2024-03-19 15:47:13 -04:00
Matt Nadareski
0713dfafb2 Bump version 2024-03-12 16:35:45 -04:00
Matt Nadareski
c0d4f403c3 Update IO package 2024-03-12 16:34:32 -04:00
Matt Nadareski
5ed79166cf Update Models library 2024-03-12 16:29:05 -04:00
Matt Nadareski
17030cfb9f Fix Listxml type key issues 2024-03-12 12:58:27 -04:00
Matt Nadareski
530fa69d3c Fix OpenMSX cross-model serialization keys 2024-03-12 00:46:46 -04:00
Matt Nadareski
7a5956f599 Fix capitalization in RomCenter INI stream serializer 2024-03-11 23:08:10 -04:00
Matt Nadareski
5562768509 Fix separated value cross-model serialization 2024-03-11 22:47:38 -04:00
Matt Nadareski
aa538df229 All doctype overloads to take nullable objects 2024-03-11 22:31:40 -04:00
Matt Nadareski
b7b22cba32 Fix AttractMode writing 2024-03-11 14:52:32 -04:00
Matt Nadareski
fc489125d9 Fix serialization problem for listrom 2024-03-10 00:39:23 -05:00
Matt Nadareski
036589473d Fix serialziation problem for archive.org 2024-03-10 00:36:31 -05:00
Matt Nadareski
432ce85f89 Bump version 2024-03-05 11:16:22 -05:00
Matt Nadareski
438e8067eb Update SabreTools.IO 2024-03-05 11:12:59 -05:00
Matt Nadareski
9715507aaf Add nuget package and PR workflows 2024-02-27 19:17:20 -05:00
280 changed files with 2889 additions and 2956 deletions

43
.github/workflows/build_nupkg.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Nuget Pack
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Pack
run: dotnet pack
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: 'Nuget Package'
path: 'SabreTools.Serialization/bin/Release/*.nupkg'
- name: Upload to rolling
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: True
artifacts: 'SabreTools.Serialization/bin/Release/*.nupkg'
body: 'Last built commit: ${{ github.sha }}'
name: 'Rolling Release'
prerelease: True
replacesArtifacts: True
tag: "rolling"
updateOnlyUnreleased: True

17
.github/workflows/check_pr.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Build PR
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
run: dotnet build

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,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,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,42 +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="obj">Data to serialize</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,30 @@ 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 |
| `IByteSerializer` | Model | `byte[]?` |
| `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

@@ -10,7 +10,7 @@ namespace SabreTools.Serialization.CrossModel
{
if (item == null)
return null;
var metadataFile = new Models.Metadata.MetadataFile
{
[Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
@@ -45,10 +45,12 @@ namespace SabreTools.Serialization.CrossModel
/// </summary>
private static Models.Metadata.Machine ConvertMachineToInternalModel(Models.ArchiveDotOrg.File? item)
{
var machine = new Models.Metadata.Machine
{
[Models.Metadata.Machine.RomKey] = ConvertToInternalModel(item),
};
var machine = new Models.Metadata.Machine();
var rom = ConvertToInternalModel(item);
if (rom != null)
machine[Models.Metadata.Machine.RomKey] = new Models.Metadata.Rom[] { rom };
return machine;
}

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)

View File

@@ -65,8 +65,8 @@ namespace SabreTools.Serialization.CrossModel
datItems.Add(ConvertToInternalModel(file));
}
machine[Models.Metadata.Machine.DiskKey] = datItems.Where(i => i.ReadString(Models.Metadata.DatItem.TypeKey) == "disk")?.ToArray();
machine[Models.Metadata.Machine.RomKey] = datItems.Where(i => i.ReadString(Models.Metadata.DatItem.TypeKey) == "rom")?.ToArray();
machine[Models.Metadata.Machine.DiskKey] = datItems.Where(i => i.ReadString(Models.Metadata.DatItem.TypeKey) == "disk").Select(d => d as Models.Metadata.Disk).ToArray();
machine[Models.Metadata.Machine.RomKey] = datItems.Where(i => i.ReadString(Models.Metadata.DatItem.TypeKey) == "rom").Select(d => d as Models.Metadata.Rom).ToArray();
}
return machine;
@@ -81,6 +81,7 @@ namespace SabreTools.Serialization.CrossModel
{
var disk = new Models.Metadata.Disk
{
[Models.Metadata.DatItem.TypeKey] = "disk",
[Models.Metadata.Disk.NameKey] = item.Name,
[Models.Metadata.Disk.MD5Key] = item.MD5,
[Models.Metadata.Disk.SHA1Key] = item.SHA1,
@@ -97,6 +98,7 @@ namespace SabreTools.Serialization.CrossModel
{
var rom = new Models.Metadata.Rom
{
[Models.Metadata.DatItem.TypeKey] = "rom",
[Models.Metadata.Rom.NameKey] = item.Name,
[Models.Metadata.Rom.SizeKey] = item.Size,
[Models.Metadata.Rom.CRCKey] = item.CRC,

View File

@@ -308,7 +308,7 @@ namespace SabreTools.Serialization.CrossModel
{
Name = item.ReadString(Models.Metadata.Chip.NameKey),
Tag = item.ReadString(Models.Metadata.Chip.TagKey),
Type = item.ReadString(Models.Metadata.Chip.TypeKey),
Type = item.ReadString(Models.Metadata.Chip.ChipTypeKey),
SoundOnly = item.ReadString(Models.Metadata.Chip.SoundOnlyKey),
Clock = item.ReadString(Models.Metadata.Chip.ClockKey),
};
@@ -407,7 +407,7 @@ namespace SabreTools.Serialization.CrossModel
{
var control = new Control
{
Type = item.ReadString(Models.Metadata.Control.TypeKey),
Type = item.ReadString(Models.Metadata.Control.ControlTypeKey),
Player = item.ReadString(Models.Metadata.Control.PlayerKey),
Buttons = item.ReadString(Models.Metadata.Control.ButtonsKey),
ReqButtons = item.ReadString(Models.Metadata.Control.ReqButtonsKey),
@@ -430,7 +430,7 @@ namespace SabreTools.Serialization.CrossModel
{
var device = new Device
{
Type = item.ReadString(Models.Metadata.Device.TypeKey),
Type = item.ReadString(Models.Metadata.Device.DeviceTypeKey),
Tag = item.ReadString(Models.Metadata.Device.TagKey),
FixedImage = item.ReadString(Models.Metadata.Device.FixedImageKey),
Mandatory = item.ReadString(Models.Metadata.Device.MandatoryKey),
@@ -563,7 +563,7 @@ namespace SabreTools.Serialization.CrossModel
var display = new Display
{
Tag = item.ReadString(Models.Metadata.Display.TagKey),
Type = item.ReadString(Models.Metadata.Display.TypeKey),
Type = item.ReadString(Models.Metadata.Display.DisplayTypeKey),
Rotate = item.ReadString(Models.Metadata.Display.RotateKey),
FlipX = item.ReadString(Models.Metadata.Display.FlipXKey),
Width = item.ReadString(Models.Metadata.Display.WidthKey),
@@ -621,7 +621,7 @@ namespace SabreTools.Serialization.CrossModel
{
var feature = new Feature
{
Type = item.ReadString(Models.Metadata.Feature.TypeKey),
Type = item.ReadString(Models.Metadata.Feature.FeatureTypeKey),
Status = item.ReadString(Models.Metadata.Feature.StatusKey),
Overall = item.ReadString(Models.Metadata.Feature.OverallKey),
};

View File

@@ -264,7 +264,7 @@ namespace SabreTools.Serialization.CrossModel
{
[Models.Metadata.Chip.NameKey] = item.Name,
[Models.Metadata.Chip.TagKey] = item.Tag,
[Models.Metadata.Chip.TypeKey] = item.Type,
[Models.Metadata.Chip.ChipTypeKey] = item.Type,
[Models.Metadata.Chip.SoundOnlyKey] = item.SoundOnly,
[Models.Metadata.Chip.ClockKey] = item.Clock,
};
@@ -359,7 +359,7 @@ namespace SabreTools.Serialization.CrossModel
{
var control = new Models.Metadata.Control
{
[Models.Metadata.Control.TypeKey] = item.Type,
[Models.Metadata.Control.ControlTypeKey] = item.Type,
[Models.Metadata.Control.PlayerKey] = item.Player,
[Models.Metadata.Control.ButtonsKey] = item.Buttons,
[Models.Metadata.Control.ReqButtonsKey] = item.ReqButtons,
@@ -382,7 +382,7 @@ namespace SabreTools.Serialization.CrossModel
{
var device = new Models.Metadata.Device
{
[Models.Metadata.Device.TypeKey] = item.Type,
[Models.Metadata.Device.DeviceTypeKey] = item.Type,
[Models.Metadata.Device.TagKey] = item.Tag,
[Models.Metadata.Device.FixedImageKey] = item.FixedImage,
[Models.Metadata.Device.MandatoryKey] = item.Mandatory,
@@ -509,7 +509,7 @@ namespace SabreTools.Serialization.CrossModel
var display = new Models.Metadata.Display
{
[Models.Metadata.Display.TagKey] = item.Tag,
[Models.Metadata.Display.TypeKey] = item.Type,
[Models.Metadata.Display.DisplayTypeKey] = item.Type,
[Models.Metadata.Display.RotateKey] = item.Rotate,
[Models.Metadata.Display.FlipXKey] = item.FlipX,
[Models.Metadata.Display.WidthKey] = item.Width,
@@ -567,7 +567,7 @@ namespace SabreTools.Serialization.CrossModel
{
var feature = new Models.Metadata.Feature
{
[Models.Metadata.Feature.TypeKey] = item.Type,
[Models.Metadata.Feature.FeatureTypeKey] = item.Type,
[Models.Metadata.Feature.StatusKey] = item.Status,
[Models.Metadata.Feature.OverallKey] = item.Overall,
};

View File

@@ -100,7 +100,7 @@ namespace SabreTools.Serialization.CrossModel
var megaRom = new MegaRom
{
Start = item.ReadString(Models.Metadata.Rom.StartKey),
Type = item.ReadString(Models.Metadata.Rom.TypeKey),
Type = item.ReadString(Models.Metadata.Rom.OpenMSXType),
Hash = item.ReadString(Models.Metadata.Rom.SHA1Key),
Remark = item.ReadString(Models.Metadata.Rom.RemarkKey),
};
@@ -128,7 +128,7 @@ namespace SabreTools.Serialization.CrossModel
var rom = new Rom
{
Start = item.ReadString(Models.Metadata.Rom.StartKey),
Type = item.ReadString(Models.Metadata.Rom.TypeKey),
Type = item.ReadString(Models.Metadata.Rom.OpenMSXType),
Hash = item.ReadString(Models.Metadata.Rom.SHA1Key),
Remark = item.ReadString(Models.Metadata.Rom.RemarkKey),
};
@@ -143,7 +143,7 @@ namespace SabreTools.Serialization.CrossModel
var sccPlusCart = new SCCPlusCart
{
Start = item.ReadString(Models.Metadata.Rom.StartKey),
Type = item.ReadString(Models.Metadata.Rom.TypeKey),
Type = item.ReadString(Models.Metadata.Rom.OpenMSXType),
Hash = item.ReadString(Models.Metadata.Rom.SHA1Key),
Remark = item.ReadString(Models.Metadata.Rom.RemarkKey),
};

View File

@@ -118,7 +118,7 @@ namespace SabreTools.Serialization.CrossModel
var rom = new Models.Metadata.Rom
{
[Models.Metadata.Rom.StartKey] = item.Start,
[Models.Metadata.Rom.TypeKey] = item.Type,
[Models.Metadata.Rom.OpenMSXType] = item.Type,
[Models.Metadata.Rom.SHA1Key] = item.Hash,
[Models.Metadata.Rom.RemarkKey] = item.Remark,
};

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