mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-04 13:45:40 +00:00
Compare commits
134 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bf78c78e3 | ||
|
|
e38ecaec4c | ||
|
|
af40c78b56 | ||
|
|
12b206f9fa | ||
|
|
2cc51ba089 | ||
|
|
52f0846d5d | ||
|
|
3fa8848e77 | ||
|
|
41276e3d7e | ||
|
|
4cef93c95e | ||
|
|
cdd999ee03 | ||
|
|
4f253323db | ||
|
|
351f749e20 | ||
|
|
1e83fc4b9a | ||
|
|
c532bd1063 | ||
|
|
e4631a8176 | ||
|
|
ee8dad0c87 | ||
|
|
4163b2f22a | ||
|
|
6aaf3afa38 | ||
|
|
2a7eb44281 | ||
|
|
08bbc93793 | ||
|
|
789478df13 | ||
|
|
cd4f1c9d97 | ||
|
|
1a2e9fb942 | ||
|
|
d0865739de | ||
|
|
0696bbab72 | ||
|
|
4b4c17ac24 | ||
|
|
d768172da1 | ||
|
|
2a4d24309d | ||
|
|
bc01ce4552 | ||
|
|
ef0efe66bd | ||
|
|
7c21f65723 | ||
|
|
cec53e907f | ||
|
|
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 | ||
|
|
33905165f7 | ||
|
|
83ec3b6950 | ||
|
|
9b5d51884c | ||
|
|
aaa6422921 | ||
|
|
f24b88031b | ||
|
|
edf9fed751 | ||
|
|
beca747943 | ||
|
|
58e538eff6 | ||
|
|
4f04c8aa89 | ||
|
|
d7c1e4e83a | ||
|
|
975eefdc61 | ||
|
|
d8cd5854ce | ||
|
|
0790fc93b6 | ||
|
|
7f6c128521 | ||
|
|
87df6b3ebd | ||
|
|
2ca7326074 | ||
|
|
3b90af7b3a | ||
|
|
6eda2f2541 | ||
|
|
defe1c53aa | ||
|
|
e5fe0a71ef | ||
|
|
83450f693f | ||
|
|
1f70e1f544 | ||
|
|
4bfc83d5d4 | ||
|
|
7364661900 | ||
|
|
1cafc4079d | ||
|
|
0d62cbd1e9 | ||
|
|
bf753262a5 | ||
|
|
5510b5d19d | ||
|
|
d0f0ade757 | ||
|
|
26b03d8256 | ||
|
|
97f685512a | ||
|
|
0f790869d8 | ||
|
|
608edeb630 | ||
|
|
56066877b1 | ||
|
|
a530f271d0 | ||
|
|
327fd68f04 | ||
|
|
f12d48861f | ||
|
|
5a613be9bf | ||
|
|
226031f3bd | ||
|
|
e5edf43624 |
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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.AACS;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class AACS : IByteSerializer<MediaKeyBlock>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MediaKeyBlock Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public MediaKeyBlock? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.BDPlus;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class BDPlus : IByteSerializer<SVM>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public SVM Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public SVM? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.BFPK;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class BFPK : IByteSerializer<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Archive Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class BSP : IByteSerializer<Models.BSP.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.BSP.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.BSP.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.CFB;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class CFB : IByteSerializer<Binary>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Binary Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Binary? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class CIA : IByteSerializer<Models.N3DS.CIA>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.N3DS.CIA Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.N3DS.CIA? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class GCF : IByteSerializer<Models.GCF.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.GCF.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.GCF.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,29 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.InstallShieldCabinet;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
// TODO: Add multi-cabinet reading
|
||||
public partial class InstallShieldCabinet : IByteSerializer<Cabinet>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Cabinet Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Cabinet? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.LinearExecutable;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class LinearExecutable : IByteSerializer<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Executable Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.MSDOS;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class MSDOS : IByteSerializer<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Executable Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,29 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.MicrosoftCabinet;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
// TODO: Add multi-cabinet reading
|
||||
public partial class MicrosoftCabinet : IByteSerializer<Cabinet>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Cabinet Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Cabinet? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.MoPaQ;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class MoPaQ : IByteSerializer<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Archive Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.N3DS;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class N3DS : IByteSerializer<Cart>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Cart Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Cart? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class NCF : IByteSerializer<Models.NCF.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.NCF.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.NCF.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.NewExecutable;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class NewExecutable : IByteSerializer<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Executable Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.Nitro;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class Nitro : IByteSerializer<Cart>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Cart Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Cart? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PAK : IByteSerializer<Models.PAK.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.PAK.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.PAK.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.PFF;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PFF : IByteSerializer<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Archive Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.PlayJ;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PlayJAudio : IByteSerializer<AudioFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public AudioFile Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public AudioFile? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.PlayJ;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PlayJPlaylist : IByteSerializer<Playlist>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Playlist Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Playlist? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.PortableExecutable;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PortableExecutable : IByteSerializer<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Executable Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,28 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.Quantum;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class Quantum : IByteSerializer<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Archive Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class SGA : IByteSerializer<Models.SGA.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.SGA.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.SGA.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class VBSP : IByteSerializer<Models.VBSP.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.VBSP.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.VBSP.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class VPK : IByteSerializer<Models.VPK.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.VPK.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.VPK.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class WAD : IByteSerializer<Models.WAD.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.WAD.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.WAD.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,27 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class XZP : IByteSerializer<Models.XZP.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.XZP.File Deserialize(byte[] data, int offset)
|
||||
#else
|
||||
public Models.XZP.File? Deserialize(byte[]? data, int offset)
|
||||
#endif
|
||||
{
|
||||
// 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,20 +0,0 @@
|
||||
using SabreTools.Models.AttractMode;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class AttractMode : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path)
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
#endif
|
||||
{
|
||||
using (var stream = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.AttractMode().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.AttractMode;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class AttractMode : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path)
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,27 +0,0 @@
|
||||
using SabreTools.Models.ClrMamePro;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class ClrMamePro : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path) => Deserialize(path, true);
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path) => Deserialize(path, true);
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path, bool quotes)
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path, bool quotes)
|
||||
#endif
|
||||
{
|
||||
using (var stream = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.ClrMamePro().Deserialize(stream, quotes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.ClrMamePro;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class ClrMamePro : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path) => Serialize(obj, path, true);
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path) => Serialize(obj, path, true);
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="Serialize(MetadataFile, string)"/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path, bool quotes)
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path, bool quotes)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,20 +0,0 @@
|
||||
using SabreTools.Models.DosCenter;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class DosCenter : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path)
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
#endif
|
||||
{
|
||||
using (var stream = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.DosCenter().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using SabreTools.Models.DosCenter;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class DosCenter : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path)
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,20 +0,0 @@
|
||||
using SabreTools.Models.EverdriveSMDB;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class EverdriveSMDB : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path)
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
#endif
|
||||
{
|
||||
using (var stream = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.EverdriveSMDB().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using SabreTools.Models.EverdriveSMDB;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class EverdriveSMDB : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path)
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,25 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class Hashfile : IFileSerializer<Models.Hashfile.Hashfile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Hashfile.Hashfile Deserialize(string path) => Deserialize(path, Hash.CRC);
|
||||
#else
|
||||
public Models.Hashfile.Hashfile? Deserialize(string? path) => Deserialize(path, Hash.CRC);
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Hashfile.Hashfile Deserialize(string path, Hash hash)
|
||||
#else
|
||||
public Models.Hashfile.Hashfile? Deserialize(string? path, Hash hash)
|
||||
#endif
|
||||
{
|
||||
using (var stream = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.Hashfile().Deserialize(stream, hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class Hashfile : IFileSerializer<Models.Hashfile.Hashfile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(Models.Hashfile.Hashfile obj, string path) => Serialize(obj, path, Hash.CRC);
|
||||
#else
|
||||
public bool Serialize(Models.Hashfile.Hashfile? obj, string? path) => Serialize(obj, path, Hash.CRC);
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(Models.Hashfile.Hashfile obj, string path, Hash hash)
|
||||
#else
|
||||
public bool Serialize(Models.Hashfile.Hashfile? obj, string? path, Hash hash)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,20 +0,0 @@
|
||||
using SabreTools.Models.Listrom;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class Listrom : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path)
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
#endif
|
||||
{
|
||||
using (var stream = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.Listrom().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using SabreTools.Models.Listrom;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class Listrom : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path)
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,20 +0,0 @@
|
||||
using SabreTools.Models.RomCenter;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class RomCenter : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path)
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
#endif
|
||||
{
|
||||
using (var stream = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.RomCenter().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using SabreTools.Models.RomCenter;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class RomCenter : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path)
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,27 +0,0 @@
|
||||
using SabreTools.Models.SeparatedValue;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class SeparatedValue : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path) => Deserialize(path, ',');
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path) => Deserialize(path, ',');
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(string path, char delim)
|
||||
#else
|
||||
public MetadataFile? Deserialize(string? path, char delim)
|
||||
#endif
|
||||
{
|
||||
using (var stream = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.SeparatedValue().Deserialize(stream, delim);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
using SabreTools.Models.SeparatedValue;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class SeparatedValue : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path) => Serialize(obj, path, ',');
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path) => Serialize(obj, path, ',');
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(MetadataFile obj, string path, char delim)
|
||||
#else
|
||||
public bool Serialize(MetadataFile? obj, string? path, char delim)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,22 +0,0 @@
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for other XML serializers
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public partial class XmlFile<T> : IFileSerializer<T>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public T Deserialize(string path)
|
||||
#else
|
||||
public T? Deserialize(string? path)
|
||||
#endif
|
||||
{
|
||||
using (var data = PathProcessor.OpenStream(path))
|
||||
{
|
||||
return new Streams.XmlFile<T>().Deserialize(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for other XML serializers
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public partial class XmlFile<T> : IFileSerializer<T>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Serialize(T obj, string path)
|
||||
#else
|
||||
public bool Serialize(T? obj, string? path)
|
||||
#endif
|
||||
=> 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>
|
||||
#if NET48
|
||||
public bool Serialize(T obj, string path, string name = null, string pubid = null, string sysid = null, string subset = null)
|
||||
#else
|
||||
public bool Serialize(T? obj, string? path, string? name = null, string? pubid = null, string? sysid = null, string? subset = null)
|
||||
#endif
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(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,33 +0,0 @@
|
||||
namespace SabreTools.Serialization
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines how to serialize to and from files
|
||||
/// </summary>
|
||||
public interface IFileSerializer<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserialize a file into <typeparamref name="T"/>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of object to deserialize to</typeparam>
|
||||
/// <param name="path">Path to deserialize from</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
#if NET48
|
||||
T Deserialize(string path);
|
||||
#else
|
||||
T? Deserialize(string? path);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Sserialize a <typeparamref name="T"/> into a file
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of object to serialize from</typeparam>
|
||||
/// <param name="obj">Data to serialize</param>
|
||||
/// <param name="path">Path to the file to serialize to</param>
|
||||
/// <returns>True on successful serialization, false otherwise</returns>
|
||||
#if NET48
|
||||
bool Serialize(T obj, string path);
|
||||
#else
|
||||
bool Serialize(T? obj, string? path);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization
|
||||
{
|
||||
/// <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>
|
||||
#if NET48
|
||||
T Deserialize(Stream data);
|
||||
#else
|
||||
T? Deserialize(Stream? data);
|
||||
#endif
|
||||
|
||||
/// <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>
|
||||
#if NET48
|
||||
Stream Serialize(T obj);
|
||||
#else
|
||||
Stream? Serialize(T? obj);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
107
Internal.cs
107
Internal.cs
@@ -1,107 +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>
|
||||
#if NET48
|
||||
public static DatItem[] ExtractItems(Dump item)
|
||||
#else
|
||||
public static DatItem[]? ExtractItems(Dump? item)
|
||||
#endif
|
||||
{
|
||||
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.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract nested items from a Part
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static DatItem[] ExtractItems(Part item)
|
||||
#else
|
||||
public static DatItem[]? ExtractItems(Part? item)
|
||||
#endif
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
var diskAreas = item.Read<DiskArea[]>(Part.DiskAreaKey);
|
||||
if (diskAreas != null && diskAreas.Any())
|
||||
{
|
||||
datItems.AddRange(diskAreas
|
||||
.Where(d => d != null)
|
||||
.SelectMany(ExtractItems));
|
||||
}
|
||||
|
||||
var dipSwitches = item.Read<DipSwitch[]>(Part.DipSwitchKey);
|
||||
if (dipSwitches != null && dipSwitches.Any())
|
||||
{
|
||||
datItems.AddRange(dipSwitches
|
||||
.Where(d => d != null));
|
||||
}
|
||||
|
||||
return datItems.ToArray();
|
||||
}
|
||||
|
||||
/// <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 Array.Empty<Rom>();
|
||||
|
||||
return roms.ToArray();
|
||||
}
|
||||
|
||||
/// <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 Array.Empty<Disk>();
|
||||
|
||||
return roms.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Logiqx.cs
32
Logiqx.cs
@@ -1,32 +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>
|
||||
#if NET48
|
||||
public const string DocTypeSubset = null;
|
||||
#else
|
||||
public const string? DocTypeSubset = null;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
36
OpenMSX.cs
36
OpenMSX.cs
@@ -1,36 +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>
|
||||
#if NET48
|
||||
public const string DocTypePubId = null;
|
||||
#else
|
||||
public const string? DocTypePubId = null;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// sysid field for DOCTYPE
|
||||
/// </summary>
|
||||
public const string DocTypeSysId = "softwaredb1.dtd";
|
||||
|
||||
/// <summary>
|
||||
/// subset field for DOCTYPE
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public const string DocTypeSubset = null;
|
||||
#else
|
||||
public const string? DocTypeSubset = null;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
28
README.MD
28
README.MD
@@ -3,3 +3,31 @@
|
||||
This library comprises of serializers that both read and write from files and streams to the dedicated models as well as convert to and from the common internal models. This library is partially used by the current parsing and writing code but none of the internal model serialization is used.
|
||||
|
||||
Find the link to the Nuget package [here](https://www.nuget.org/packages/SabreTools.Serialization).
|
||||
|
||||
## Interfaces
|
||||
|
||||
Below is a table representing the various interfaces that are implemented within this library.
|
||||
|
||||
| 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 |
|
||||
|
||||
## Namespaces
|
||||
|
||||
Below is a table of all namespaces within the library and what they represent
|
||||
|
||||
| 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
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.ArchiveDotOrg;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class ArchiveDotOrg : IModelSerializer<Models.ArchiveDotOrg.Files, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.ArchiveDotOrg.Files Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public Models.ArchiveDotOrg.Files? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -37,7 +34,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var roms = item.Read<Models.Metadata.Rom[]>(Models.Metadata.Machine.RomKey);
|
||||
if (roms == null)
|
||||
return Array.Empty<File>();
|
||||
return [];
|
||||
|
||||
return roms
|
||||
.Where(r => r != null)
|
||||
@@ -1,19 +1,16 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class ArchiveDotOrg : IModelSerializer<Models.ArchiveDotOrg.Files, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(Models.ArchiveDotOrg.Files item)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(Models.ArchiveDotOrg.Files? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
|
||||
var metadataFile = new Models.Metadata.MetadataFile
|
||||
{
|
||||
[Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
@@ -46,27 +43,21 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.ArchiveDotOrg.File"/> to <cref="Models.Metadata.Machine"/>
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static Models.Metadata.Machine ConvertMachineToInternalModel(Models.ArchiveDotOrg.File item)
|
||||
#else
|
||||
private static Models.Metadata.Machine ConvertMachineToInternalModel(Models.ArchiveDotOrg.File? item)
|
||||
#endif
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.ArchiveDotOrg.File"/> to <cref="Models.Metadata.Rom"/>
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static Models.Metadata.Rom ConvertToInternalModel(Models.ArchiveDotOrg.File item)
|
||||
#else
|
||||
private static Models.Metadata.Rom? ConvertToInternalModel(Models.ArchiveDotOrg.File? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -1,17 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.AttractMode;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class AttractMode : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -50,7 +47,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var roms = item.Read<Models.Metadata.Rom[]>(Models.Metadata.Machine.RomKey);
|
||||
if (roms == null || !roms.Any())
|
||||
return Array.Empty<Row>();
|
||||
return [];
|
||||
|
||||
return roms
|
||||
.Where(r => r != null)
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.AttractMode;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class AttractMode : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(MetadataFile obj)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -47,11 +44,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.AttractMode.Row"/> to <cref="Models.Metadata.Machine"/>
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static Models.Metadata.Machine ConvertMachineToInternalModel(Row item)
|
||||
#else
|
||||
private static Models.Metadata.Machine? ConvertMachineToInternalModel(Row? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -1,23 +1,16 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.ClrMamePro;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class ClrMamePro : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(Models.Metadata.MetadataFile obj) => Deserialize(obj, false);
|
||||
#else
|
||||
public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, false);
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Models.Metadata.MetadataFile)"/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(Models.Metadata.MetadataFile obj, bool game)
|
||||
#else
|
||||
public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj, bool game)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -71,15 +64,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// </summary>
|
||||
private static GameBase ConvertMachineFromInternalModel(Models.Metadata.Machine item, bool game = false)
|
||||
{
|
||||
#if NET48
|
||||
GameBase gameBase;
|
||||
if (game)
|
||||
gameBase = new Game();
|
||||
else
|
||||
gameBase = new Machine();
|
||||
#else
|
||||
GameBase gameBase = game ? new Models.ClrMamePro.Game() : new Models.ClrMamePro.Machine();
|
||||
#endif
|
||||
|
||||
gameBase.Name = item.ReadString(Models.Metadata.Machine.NameKey);
|
||||
gameBase.Description = item.ReadString(Models.Metadata.Machine.DescriptionKey);
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.ClrMamePro;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class ClrMamePro : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(MetadataFile obj)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -61,11 +58,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.ClrMamePro.GameBase"/> to <cref="Models.Metadata.Machine"/>
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static Models.Metadata.Machine ConvertMachineToInternalModel(GameBase item)
|
||||
#else
|
||||
private static Models.Metadata.Machine? ConvertMachineToInternalModel(GameBase? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.DosCenter;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class DosCenter : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.DosCenter;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class DosCenter : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(MetadataFile obj)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,17 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.EverdriveSMDB;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class EverdriveSMDB : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -37,7 +34,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var roms = item.Read<Models.Metadata.Rom[]>(Models.Metadata.Machine.RomKey);
|
||||
if (roms == null || !roms.Any())
|
||||
return Array.Empty<Row>();
|
||||
return [];
|
||||
|
||||
return roms
|
||||
.Where(r => r != null)
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.EverdriveSMDB;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class EverdriveSMDB : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(MetadataFile obj)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,24 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SabreTools.Hashing;
|
||||
using SabreTools.Models.Hashfile;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class Hashfile : IModelSerializer<Models.Hashfile.Hashfile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Hashfile.Hashfile Deserialize(Models.Metadata.MetadataFile obj) => Deserialize(obj, Hash.CRC);
|
||||
#else
|
||||
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, Hash.CRC);
|
||||
#endif
|
||||
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, HashType.CRC32);
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Hashfile.Hashfile Deserialize(Models.Metadata.MetadataFile obj, Hash hash)
|
||||
#else
|
||||
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj, Hash hash)
|
||||
#endif
|
||||
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj, HashType hash)
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -80,11 +74,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Metadata.MetadataFile"/> to an array of <cref="Models.Hashfile.Hashfile"/>
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static Models.Hashfile.Hashfile[] ConvertArrayFromInternalModel(Models.Metadata.MetadataFile item, Hash hash)
|
||||
#else
|
||||
public static Models.Hashfile.Hashfile[]? ConvertArrayFromInternalModel(Models.Metadata.MetadataFile? item, Hash hash)
|
||||
#endif
|
||||
public static Models.Hashfile.Hashfile[]? ConvertArrayFromInternalModel(Models.Metadata.MetadataFile? item, HashType hash)
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -104,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)
|
||||
@@ -112,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)
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.Hashfile;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class Hashfile : IModelSerializer<Models.Hashfile.Hashfile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(Models.Hashfile.Hashfile obj)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(Models.Hashfile.Hashfile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,17 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.Listrom;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class Listrom : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,17 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.Listrom;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class Listrom : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(MetadataFile obj)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -50,7 +47,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
private static Models.Metadata.Machine ConvertMachineToInternalModel(Set item)
|
||||
{
|
||||
var machine = new Models.Metadata.Machine();
|
||||
if (!string.IsNullOrWhiteSpace(item.Device))
|
||||
if (!string.IsNullOrEmpty(item.Device))
|
||||
{
|
||||
machine[Models.Metadata.Machine.NameKey] = item.Device;
|
||||
machine[Models.Metadata.Machine.IsDeviceKey] = "yes";
|
||||
@@ -68,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;
|
||||
@@ -84,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,
|
||||
@@ -100,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,
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.Listxml;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class Listxml : IModelSerializer<Mame, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Mame Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public Mame? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -33,11 +30,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Metadata.Models.Metadata.MetadataFile"/> to <cref="Models.Listxml.Mame"/>
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static Mame ConvertMameFromInternalModel(Models.Metadata.MetadataFile item)
|
||||
#else
|
||||
public static Mame? ConvertMameFromInternalModel(Models.Metadata.MetadataFile? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -315,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),
|
||||
};
|
||||
@@ -414,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),
|
||||
@@ -437,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),
|
||||
@@ -570,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),
|
||||
@@ -628,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),
|
||||
};
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.Listxml;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class Listxml : IModelSerializer<Mame, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(Mame item)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(Mame? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -267,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,
|
||||
};
|
||||
@@ -362,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,
|
||||
@@ -385,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,
|
||||
@@ -512,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,
|
||||
@@ -570,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,
|
||||
};
|
||||
@@ -1,24 +1,16 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.Logiqx;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class Logiqx : IModelSerializer<Datafile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Datafile Deserialize(Models.Metadata.MetadataFile obj) => Deserialize(obj, false);
|
||||
#else
|
||||
public Datafile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, false);
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Datafile Deserialize(Models.Metadata.MetadataFile obj, bool game)
|
||||
#else
|
||||
public Datafile? Deserialize(Models.Metadata.MetadataFile? obj, bool game)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -111,15 +103,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// </summary>
|
||||
private static GameBase ConvertMachineFromInternalModel(Models.Metadata.Machine item, bool game = false)
|
||||
{
|
||||
#if NET48
|
||||
GameBase gameBase;
|
||||
if (game)
|
||||
gameBase = new Game();
|
||||
else
|
||||
gameBase = new Machine();
|
||||
#else
|
||||
GameBase gameBase = game ? new Game() : new Machine();
|
||||
#endif
|
||||
|
||||
gameBase.Name = item.ReadString(Models.Metadata.Machine.NameKey);
|
||||
gameBase.SourceFile = item.ReadString(Models.Metadata.Machine.SourceFileKey);
|
||||
@@ -2,16 +2,13 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.Logiqx;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class Logiqx : IModelSerializer<Datafile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(Datafile item)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(Datafile? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -25,9 +22,9 @@ namespace SabreTools.Serialization.CrossModel
|
||||
|
||||
if (item.Game != null && item.Game.Any())
|
||||
{
|
||||
machines.AddRange(item.Game
|
||||
.Where(g => g != null)
|
||||
.Select(ConvertMachineToInternalModel));
|
||||
machines.AddRange(item.Game
|
||||
.Where(g => g != null)
|
||||
.Select(ConvertMachineToInternalModel));
|
||||
}
|
||||
|
||||
if (item.Dir != null && item.Dir.Any())
|
||||
@@ -107,7 +104,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
private static Models.Metadata.Machine[] ConvertDirToInternalModel(Dir item)
|
||||
{
|
||||
if (item.Game == null || !item.Game.Any())
|
||||
return Array.Empty<Models.Metadata.Machine>();
|
||||
return [];
|
||||
|
||||
return item.Game
|
||||
.Where(g => g != null)
|
||||
@@ -1,15 +1,12 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class M1 : IModelSerializer<Models.Listxml.M1, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Listxml.M1 Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public Models.Listxml.M1? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,15 +1,12 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class M1 : IModelSerializer<Models.Listxml.M1, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(Models.Listxml.M1 item)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(Models.Listxml.M1? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.OfflineList;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class OfflineList : IModelSerializer<Dat, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Dat Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public Dat? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.OfflineList;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class OfflineList : IModelSerializer<Dat, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(Dat item)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(Dat? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.OpenMSX;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class OpenMSX : IModelSerializer<SoftwareDb, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public SoftwareDb Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public SoftwareDb? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -103,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),
|
||||
};
|
||||
@@ -131,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),
|
||||
};
|
||||
@@ -146,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),
|
||||
};
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.OpenMSX;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class OpenMSX : IModelSerializer<SoftwareDb, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(SoftwareDb item)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(SoftwareDb? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -121,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,
|
||||
};
|
||||
@@ -1,17 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.RomCenter;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class RomCenter : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -94,7 +91,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var roms = item.Read<Models.Metadata.Rom[]>(Models.Metadata.Machine.RomKey);
|
||||
if (roms == null)
|
||||
return Array.Empty<Rom>();
|
||||
return [];
|
||||
|
||||
return roms
|
||||
.Where(r => r != null)
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.RomCenter;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class RomCenter : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(MetadataFile obj)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,17 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SabreTools.Models.SeparatedValue;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class SeparatedValue : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public MetadataFile Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public MetadataFile? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -24,7 +21,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
metadataFile.Row = machines
|
||||
.Where(m => m != null)
|
||||
.SelectMany(ConvertMachineFromInternalModel)
|
||||
.SelectMany(m => ConvertMachineFromInternalModel(m, header))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
@@ -46,7 +43,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Metadata.Machine"/> to an array of <cref="Models.SeparatedValue.Row"/>
|
||||
/// </summary>
|
||||
private static Row[] ConvertMachineFromInternalModel(Models.Metadata.Machine item)
|
||||
private static Row[] ConvertMachineFromInternalModel(Models.Metadata.Machine item, Models.Metadata.Header? header)
|
||||
{
|
||||
var rowItems = new List<Row>();
|
||||
|
||||
@@ -55,7 +52,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
rowItems.AddRange(roms
|
||||
.Where(r => r != null)
|
||||
.Select(rom => ConvertFromInternalModel(rom, item)));
|
||||
.Select(rom => ConvertFromInternalModel(rom, item, header)));
|
||||
}
|
||||
|
||||
var disks = item.Read<Models.Metadata.Disk[]>(Models.Metadata.Machine.DiskKey);
|
||||
@@ -63,7 +60,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
rowItems.AddRange(disks
|
||||
.Where(d => d != null)
|
||||
.Select(disk => ConvertFromInternalModel(disk, item)));
|
||||
.Select(disk => ConvertFromInternalModel(disk, item, header)));
|
||||
}
|
||||
|
||||
var media = item.Read<Models.Metadata.Media[]>(Models.Metadata.Machine.MediaKey);
|
||||
@@ -71,7 +68,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
rowItems.AddRange(media
|
||||
.Where(m => m != null)
|
||||
.Select(medium => ConvertFromInternalModel(medium, item)));
|
||||
.Select(medium => ConvertFromInternalModel(medium, item, header)));
|
||||
}
|
||||
|
||||
return rowItems.ToArray();
|
||||
@@ -80,16 +77,26 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Metadata.Disk"/> to <cref="Models.SeparatedValue.Row"/>
|
||||
/// </summary>
|
||||
private static Row ConvertFromInternalModel(Models.Metadata.Disk item, Models.Metadata.Machine parent)
|
||||
private static Row ConvertFromInternalModel(Models.Metadata.Disk item, Models.Metadata.Machine parent, Models.Metadata.Header? header)
|
||||
{
|
||||
var row = new Row
|
||||
{
|
||||
FileName = header?.ReadString("FILENAME"), // TODO: Make this an actual key to retrieve
|
||||
InternalName = header?.ReadString(Models.Metadata.Header.NameKey),
|
||||
Description = header?.ReadString(Models.Metadata.Header.DescriptionKey),
|
||||
GameName = parent.ReadString(Models.Metadata.Machine.NameKey),
|
||||
Description = parent.ReadString(Models.Metadata.Machine.DescriptionKey),
|
||||
GameDescription = parent.ReadString(Models.Metadata.Machine.DescriptionKey),
|
||||
Type = "disk",
|
||||
RomName = null,
|
||||
DiskName = item.ReadString(Models.Metadata.Disk.NameKey),
|
||||
Size = null,
|
||||
CRC = null,
|
||||
MD5 = item.ReadString(Models.Metadata.Disk.MD5Key),
|
||||
SHA1 = item.ReadString(Models.Metadata.Disk.SHA1Key),
|
||||
SHA256 = null,
|
||||
SHA384 = null,
|
||||
SHA512 = null,
|
||||
SpamSum = null,
|
||||
Status = item.ReadString(Models.Metadata.Disk.StatusKey),
|
||||
};
|
||||
return row;
|
||||
@@ -98,17 +105,25 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Metadata.Media"/> to <cref="Models.SeparatedValue.Row"/>
|
||||
/// </summary>
|
||||
private static Row ConvertFromInternalModel(Models.Metadata.Media item, Models.Metadata.Machine parent)
|
||||
private static Row ConvertFromInternalModel(Models.Metadata.Media item, Models.Metadata.Machine parent, Models.Metadata.Header? header)
|
||||
{
|
||||
var row = new Row
|
||||
{
|
||||
FileName = header?.ReadString("FILENAME"), // TODO: Make this an actual key to retrieve
|
||||
InternalName = header?.ReadString(Models.Metadata.Header.NameKey),
|
||||
Description = header?.ReadString(Models.Metadata.Header.DescriptionKey),
|
||||
GameName = parent.ReadString(Models.Metadata.Machine.NameKey),
|
||||
Description = parent.ReadString(Models.Metadata.Machine.DescriptionKey),
|
||||
GameDescription = parent.ReadString(Models.Metadata.Machine.DescriptionKey),
|
||||
Type = "media",
|
||||
RomName = null,
|
||||
DiskName = item.ReadString(Models.Metadata.Media.NameKey),
|
||||
Size = null,
|
||||
CRC = null,
|
||||
MD5 = item.ReadString(Models.Metadata.Media.MD5Key),
|
||||
SHA1 = item.ReadString(Models.Metadata.Media.SHA1Key),
|
||||
SHA256 = item.ReadString(Models.Metadata.Media.SHA256Key),
|
||||
SHA384 = null,
|
||||
SHA512 = null,
|
||||
SpamSum = item.ReadString(Models.Metadata.Media.SpamSumKey),
|
||||
};
|
||||
return row;
|
||||
@@ -117,14 +132,18 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Metadata.Rom"/> to <cref="Models.SeparatedValue.Row"/>
|
||||
/// </summary>
|
||||
private static Row ConvertFromInternalModel(Models.Metadata.Rom item, Models.Metadata.Machine parent)
|
||||
private static Row ConvertFromInternalModel(Models.Metadata.Rom item, Models.Metadata.Machine parent, Models.Metadata.Header? header)
|
||||
{
|
||||
var row = new Row
|
||||
{
|
||||
GameName = parent?.ReadString(Models.Metadata.Machine.NameKey),
|
||||
Description = parent?.ReadString(Models.Metadata.Machine.DescriptionKey),
|
||||
FileName = header?.ReadString("FILENAME"), // TODO: Make this an actual key to retrieve
|
||||
InternalName = header?.ReadString(Models.Metadata.Header.NameKey),
|
||||
Description = header?.ReadString(Models.Metadata.Header.DescriptionKey),
|
||||
GameName = parent.ReadString(Models.Metadata.Machine.NameKey),
|
||||
GameDescription = parent.ReadString(Models.Metadata.Machine.DescriptionKey),
|
||||
Type = "rom",
|
||||
RomName = item.ReadString(Models.Metadata.Rom.NameKey),
|
||||
DiskName = null,
|
||||
Size = item.ReadString(Models.Metadata.Rom.SizeKey),
|
||||
CRC = item.ReadString(Models.Metadata.Rom.CRCKey),
|
||||
MD5 = item.ReadString(Models.Metadata.Rom.MD5Key),
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.SeparatedValue;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class SeparatedValue : IModelSerializer<MetadataFile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(MetadataFile obj)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -77,53 +74,6 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return machine;
|
||||
}
|
||||
|
||||
#if NET48
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.SeparatedValue.Row"/> to <cref="Models.Metadata.DatItem"/>
|
||||
/// </summary>
|
||||
private static Models.Metadata.DatItem ConvertToInternalModel(Row item)
|
||||
{
|
||||
switch (item.Type)
|
||||
{
|
||||
case "disk":
|
||||
return new Models.Metadata.Disk
|
||||
{
|
||||
[Models.Metadata.Disk.NameKey] = item.DiskName,
|
||||
[Models.Metadata.Disk.MD5Key] = item.MD5,
|
||||
[Models.Metadata.Disk.SHA1Key] = item.SHA1,
|
||||
[Models.Metadata.Disk.StatusKey] = item.Status,
|
||||
};
|
||||
|
||||
case "media":
|
||||
return new Models.Metadata.Media
|
||||
{
|
||||
[Models.Metadata.Media.NameKey] = item.DiskName,
|
||||
[Models.Metadata.Media.MD5Key] = item.MD5,
|
||||
[Models.Metadata.Media.SHA1Key] = item.SHA1,
|
||||
[Models.Metadata.Media.SHA256Key] = item.SHA256,
|
||||
[Models.Metadata.Media.SpamSumKey] = item.SpamSum,
|
||||
};
|
||||
|
||||
case "rom":
|
||||
return new Models.Metadata.Rom
|
||||
{
|
||||
[Models.Metadata.Rom.NameKey] = item.RomName,
|
||||
[Models.Metadata.Rom.SizeKey] = item.Size,
|
||||
[Models.Metadata.Rom.CRCKey] = item.CRC,
|
||||
[Models.Metadata.Rom.MD5Key] = item.MD5,
|
||||
[Models.Metadata.Rom.SHA1Key] = item.SHA1,
|
||||
[Models.Metadata.Rom.SHA256Key] = item.SHA256,
|
||||
[Models.Metadata.Rom.SHA384Key] = item.SHA384,
|
||||
[Models.Metadata.Rom.SHA512Key] = item.SHA512,
|
||||
[Models.Metadata.Rom.SpamSumKey] = item.SpamSum,
|
||||
[Models.Metadata.Rom.StatusKey] = item.Status,
|
||||
};
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.SeparatedValue.Row"/> to <cref="Models.Metadata.DatItem"/>
|
||||
/// </summary>
|
||||
@@ -162,6 +112,5 @@ namespace SabreTools.Serialization.CrossModel
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.SoftwareList;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class SoftwareList : IModelSerializer<Models.SoftwareList.SoftwareList, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.SoftwareList.SoftwareList Deserialize(Models.Metadata.MetadataFile obj)
|
||||
#else
|
||||
public Models.SoftwareList.SoftwareList? Deserialize(Models.Metadata.MetadataFile? obj)
|
||||
#endif
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -1,16 +1,13 @@
|
||||
using System.Linq;
|
||||
using SabreTools.Models.SoftwareList;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
public partial class SoftwareList : IModelSerializer<Models.SoftwareList.SoftwareList, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Models.Metadata.MetadataFile Serialize(Models.SoftwareList.SoftwareList item)
|
||||
#else
|
||||
public Models.Metadata.MetadataFile? Serialize(Models.SoftwareList.SoftwareList? item)
|
||||
#endif
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user