mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-04 05:36:12 +00:00
Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
006ced0430 | ||
|
|
bee6c0ba11 | ||
|
|
3cb880ff3f | ||
|
|
f1d54e4a14 | ||
|
|
f4aaed7f9c | ||
|
|
46ad76c5d2 | ||
|
|
8f731cebc8 | ||
|
|
6dbf9dacd6 | ||
|
|
94ab760c67 | ||
|
|
4ed3880bad | ||
|
|
ff8dcd30a5 | ||
|
|
8ced91d0fa | ||
|
|
f2c6fa2b8e | ||
|
|
9b1bacd167 | ||
|
|
964c97200c | ||
|
|
a3f3384ac9 | ||
|
|
8b546fbf27 | ||
|
|
15da711087 | ||
|
|
bfee7dd449 | ||
|
|
9de2a91e80 | ||
|
|
bf50c801b2 | ||
|
|
c19a4a94f4 | ||
|
|
b6fe94116b | ||
|
|
bcf604c773 | ||
|
|
74984a9114 | ||
|
|
8c1e241286 | ||
|
|
f666d737cb | ||
|
|
a01609f1d1 | ||
|
|
8ca9ccaf00 | ||
|
|
fc5374108c | ||
|
|
15452ded52 | ||
|
|
49c6c4412b | ||
|
|
cfc53f66a8 | ||
|
|
ec1fb7247c | ||
|
|
54b1eef8ae | ||
|
|
f448314309 | ||
|
|
c4e8debb15 | ||
|
|
822839c813 | ||
|
|
27d36a11ca | ||
|
|
92d9ca932d | ||
|
|
69e1f5ff0b | ||
|
|
d265c14841 | ||
|
|
1148245226 | ||
|
|
f53d9f94e6 | ||
|
|
4e3d832834 | ||
|
|
0713dfafb2 | ||
|
|
c0d4f403c3 | ||
|
|
5ed79166cf | ||
|
|
17030cfb9f | ||
|
|
530fa69d3c | ||
|
|
7a5956f599 | ||
|
|
5562768509 | ||
|
|
aa538df229 | ||
|
|
b7b22cba32 | ||
|
|
fc489125d9 | ||
|
|
036589473d | ||
|
|
432ce85f89 | ||
|
|
438e8067eb | ||
|
|
9715507aaf | ||
|
|
b745d4b9f6 | ||
|
|
4271bd86b3 | ||
|
|
88de4be27b |
43
.github/workflows/build_nupkg.yml
vendored
Normal file
43
.github/workflows/build_nupkg.yml
vendored
Normal 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
17
.github/workflows/check_pr.yml
vendored
Normal 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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Enums.cs
13
Enums.cs
@@ -1,13 +0,0 @@
|
||||
namespace SabreTools.Serialization
|
||||
{
|
||||
public enum Hash
|
||||
{
|
||||
CRC,
|
||||
MD5,
|
||||
SHA1,
|
||||
SHA256,
|
||||
SHA384,
|
||||
SHA512,
|
||||
SpamSum,
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class ArchiveDotOrg : XmlFile<Models.ArchiveDotOrg.Files>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class ArchiveDotOrg : XmlFile<Models.ArchiveDotOrg.Files>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class Listxml : XmlFile<Models.Listxml.Mame>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class Listxml : XmlFile<Models.Listxml.Mame>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class Logiqx : XmlFile<Models.Logiqx.Datafile>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class M1 : XmlFile<Models.Listxml.M1>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class M1 : XmlFile<Models.Listxml.M1>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class OfflineList : XmlFile<Models.OfflineList.Dat>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class OfflineList : XmlFile<Models.OfflineList.Dat>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class OpenMSX : XmlFile<Models.OpenMSX.SoftwareDb>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class SoftwareList : XmlFile<Models.SoftwareList.SoftwareList>
|
||||
{
|
||||
// All serialization logic is in the base class
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
102
Internal.cs
102
Internal.cs
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Logiqx.cs
28
Logiqx.cs
@@ -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;
|
||||
}
|
||||
}
|
||||
28
OpenMSX.cs
28
OpenMSX.cs
@@ -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;
|
||||
}
|
||||
}
|
||||
39
README.MD
39
README.MD
@@ -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 |
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -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,
|
||||
@@ -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),
|
||||
};
|
||||
@@ -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,
|
||||
};
|
||||
@@ -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),
|
||||
};
|
||||
@@ -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
Reference in New Issue
Block a user