mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-04 05:36:12 +00:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
006ced0430 | ||
|
|
bee6c0ba11 | ||
|
|
3cb880ff3f | ||
|
|
f1d54e4a14 | ||
|
|
f4aaed7f9c | ||
|
|
46ad76c5d2 | ||
|
|
8f731cebc8 | ||
|
|
6dbf9dacd6 | ||
|
|
94ab760c67 | ||
|
|
4ed3880bad | ||
|
|
ff8dcd30a5 | ||
|
|
8ced91d0fa | ||
|
|
f2c6fa2b8e | ||
|
|
9b1bacd167 | ||
|
|
964c97200c | ||
|
|
a3f3384ac9 | ||
|
|
8b546fbf27 | ||
|
|
15da711087 | ||
|
|
bfee7dd449 | ||
|
|
9de2a91e80 | ||
|
|
bf50c801b2 | ||
|
|
c19a4a94f4 | ||
|
|
b6fe94116b | ||
|
|
bcf604c773 | ||
|
|
74984a9114 | ||
|
|
8c1e241286 | ||
|
|
f666d737cb | ||
|
|
a01609f1d1 | ||
|
|
8ca9ccaf00 |
39
README.MD
39
README.MD
@@ -4,26 +4,29 @@ This library comprises of serializers that both read and write from files and st
|
||||
|
||||
Find the link to the Nuget package [here](https://www.nuget.org/packages/SabreTools.Serialization).
|
||||
|
||||
## `SabreTools.Serialization.Bytes`
|
||||
## Interfaces
|
||||
|
||||
This namespace comprises of deserializers that take byte arrays to convert into models.
|
||||
Below is a table representing the various interfaces that are implemented within this library.
|
||||
|
||||
## `SabreTools.Serialization.CrossModel`
|
||||
| Interface Name | Source Type | Destination Type |
|
||||
| --- | --- | --- |
|
||||
| `IByteDeserializer` | `byte[]?` | Model |
|
||||
| `IFileDeserializer` | `string?` path | Model |
|
||||
| `IFileSerializer` | Model | `string?` path |
|
||||
| `IModelSerializer` | Model | Model |
|
||||
| `IStreamDeserializer` | `Stream?` | Model |
|
||||
| `IStreamSerializer` | Model | `Stream?` |
|
||||
| `IStringDeserializer` | `string?` representation | Model |
|
||||
| `IStringSerializer` | Model | `string?` representation |
|
||||
| `IWrapper` | N/A | N/A |
|
||||
|
||||
This namespace comprises of serializers and deserializers that convert models to other common ones. This is mainly used for metadata files converting to and from a common, `Dictionary`-based model.
|
||||
## Namespaces
|
||||
|
||||
## `SabreTools.Serialization.Files`
|
||||
Below is a table of all namespaces within the library and what they represent
|
||||
|
||||
This namespace comprises of serializers and deserializers that can convert to and from files on disk. Most of the serializers are symmetric, but this is not guaranteed. Unimplemented methods will throw `NotImplementedException`.
|
||||
|
||||
## `SabreTools.Serialization.Streams`
|
||||
|
||||
This namespace comprises of serializers and deserializers that can convert to and from any type of stream. Most of the serializers are symmetric, but this is not guaranteed. Unimplemented methods will throw `NotImplementedException`.
|
||||
|
||||
## `SabreTools.Serialization.Strings`
|
||||
|
||||
This namespace comprises of serializers and deserializers that can convert to and from strings. Most of the serializers are symmetric, but this is not guaranteed. Unimplemented methods will throw `NotImplementedException`.
|
||||
|
||||
## `SabreTools.Serialization.Wrappers`
|
||||
|
||||
This namespace comrpises of wrapping classes that include keeping a reference to the source of each serializable model. Some of the wrappers may also include what are referred to as "extension properties", which are generated properties derived from either parts of the model or the underlying source.
|
||||
| Namespace | Description |
|
||||
| --- | --- |
|
||||
| `SabreTools.Serialization.CrossModel` | Convert between models; mainly used for metadata files converting to and from a common, `Dictionary`-based model |
|
||||
| `SabreTools.Serialization.Deserializers` | Convert from external sources to models |
|
||||
| `SabreTools.Serialization.Serializers` | Convert from models to external sources |
|
||||
| `SabreTools.Serialization.Wrappers` | Classes that wrap serialization and models to allow for including extension properties |
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace SabreTools.Serialization
|
||||
{
|
||||
/// <summary>
|
||||
/// Separated value serializer/deserializer for AttractMode romlists
|
||||
/// </summary>
|
||||
public static class AttractMode
|
||||
{
|
||||
public const string HeaderWithoutRomname = "#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons";
|
||||
public const int HeaderWithoutRomnameCount = 17;
|
||||
|
||||
public const string HeaderWithRomname = "#Romname;Title;Emulator;Cloneof;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons;Favourite;Tags;PlayedCount;PlayedTime;FileIsAvailable";
|
||||
public const int HeaderWithRomnameCount = 22;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.AACS;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class AACS : IByteSerializer<MediaKeyBlock>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public MediaKeyBlock? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.AACS().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.BDPlus;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class BDPlus : IByteSerializer<SVM>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public SVM? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.BDPlus().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.BFPK;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class BFPK : IByteSerializer<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.BFPK().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class BSP : IByteSerializer<Models.BSP.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.BSP.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.BSP().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.CFB;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class CFB : IByteSerializer<Binary>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Binary? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.CFB().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class CIA : IByteSerializer<Models.N3DS.CIA>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.N3DS.CIA? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.CIA().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class GCF : IByteSerializer<Models.GCF.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.GCF.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.GCF().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class IRD : IByteSerializer<Models.IRD.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.IRD.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.IRD().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.InstallShieldCabinet;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
// TODO: Add multi-cabinet reading
|
||||
public partial class InstallShieldCabinet : IByteSerializer<Cabinet>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Cabinet? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.InstallShieldCabinet().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.LinearExecutable;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class LinearExecutable : IByteSerializer<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.LinearExecutable().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.MSDOS;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class MSDOS : IByteSerializer<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.MSDOS().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.MicrosoftCabinet;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
// TODO: Add multi-cabinet reading
|
||||
public partial class MicrosoftCabinet : IByteSerializer<Cabinet>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Cabinet? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.MicrosoftCabinet().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.MoPaQ;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class MoPaQ : IByteSerializer<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.MoPaQ().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.N3DS;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class N3DS : IByteSerializer<Cart>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Cart? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.N3DS().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class NCF : IByteSerializer<Models.NCF.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.NCF.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.NCF().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.NewExecutable;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class NewExecutable : IByteSerializer<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.NewExecutable().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.Nitro;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class Nitro : IByteSerializer<Cart>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Cart? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.Nitro().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PAK : IByteSerializer<Models.PAK.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.PAK.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.PAK().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.PFF;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PFF : IByteSerializer<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.PFF().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.PlayJ;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PlayJAudio : IByteSerializer<AudioFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public AudioFile? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.PlayJAudio().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.PlayJ;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PlayJPlaylist : IByteSerializer<Playlist>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Playlist? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.PlayJPlaylist().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.PortableExecutable;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class PortableExecutable : IByteSerializer<Executable>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.PortableExecutable().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.Quantum;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class Quantum : IByteSerializer<Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.Quantum().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class SGA : IByteSerializer<Models.SGA.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.SGA.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.SGA().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class VBSP : IByteSerializer<Models.VBSP.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.VBSP.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.VBSP().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class VPK : IByteSerializer<Models.VPK.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.VPK.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.VPK().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class WAD : IByteSerializer<Models.WAD.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.WAD.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.WAD().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Bytes
|
||||
{
|
||||
public partial class XZP : IByteSerializer<Models.XZP.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.XZP.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return new Streams.XZP().Deserialize(dataStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SabreTools.Hashing;
|
||||
using SabreTools.Models.Hashfile;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
@@ -8,10 +9,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
public partial class Hashfile : IModelSerializer<Models.Hashfile.Hashfile, Models.Metadata.MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, Hash.CRC);
|
||||
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj) => Deserialize(obj, HashType.CRC32);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj, Hash hash)
|
||||
public Models.Hashfile.Hashfile? Deserialize(Models.Metadata.MetadataFile? obj, HashType hash)
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
@@ -73,7 +74,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Metadata.MetadataFile"/> to an array of <cref="Models.Hashfile.Hashfile"/>
|
||||
/// </summary>
|
||||
public static Models.Hashfile.Hashfile[]? ConvertArrayFromInternalModel(Models.Metadata.MetadataFile? item, Hash hash)
|
||||
public static Models.Hashfile.Hashfile[]? ConvertArrayFromInternalModel(Models.Metadata.MetadataFile? item, HashType hash)
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
@@ -93,7 +94,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Metadata.Machine"/> to <cref="Models.Hashfile.Hashfile"/>
|
||||
/// </summary>
|
||||
private static Models.Hashfile.Hashfile ConvertMachineFromInternalModel(Models.Metadata.Machine item, Hash hash)
|
||||
private static Models.Hashfile.Hashfile ConvertMachineFromInternalModel(Models.Metadata.Machine item, HashType hash)
|
||||
{
|
||||
var roms = item.Read<Models.Metadata.Rom[]>(Models.Metadata.Machine.RomKey);
|
||||
if (roms == null)
|
||||
@@ -101,43 +102,43 @@ namespace SabreTools.Serialization.CrossModel
|
||||
|
||||
return new Models.Hashfile.Hashfile
|
||||
{
|
||||
SFV = hash == Hash.CRC
|
||||
SFV = hash == HashType.CRC32 || hash == HashType.CRC32_ISO || hash == HashType.CRC32_Naive || hash == HashType.CRC32_Optimized || hash == HashType.CRC32_Parallel
|
||||
? roms
|
||||
.Where(r => r != null)
|
||||
.Select(ConvertToSFV)
|
||||
.ToArray()
|
||||
: null,
|
||||
MD5 = hash == Hash.MD5
|
||||
MD5 = hash == HashType.MD5
|
||||
? roms
|
||||
.Where(r => r != null)
|
||||
.Select(ConvertToMD5)
|
||||
.ToArray()
|
||||
: null,
|
||||
SHA1 = hash == Hash.SHA1
|
||||
SHA1 = hash == HashType.SHA1
|
||||
? roms
|
||||
.Where(r => r != null)
|
||||
.Select(ConvertToSHA1)
|
||||
.ToArray()
|
||||
: null,
|
||||
SHA256 = hash == Hash.SHA256
|
||||
SHA256 = hash == HashType.SHA256
|
||||
? roms
|
||||
.Where(r => r != null)
|
||||
.Select(ConvertToSHA256)
|
||||
.ToArray()
|
||||
: null,
|
||||
SHA384 = hash == Hash.SHA384
|
||||
SHA384 = hash == HashType.SHA384
|
||||
? roms
|
||||
.Where(r => r != null)
|
||||
.Select(ConvertToSHA384)
|
||||
.ToArray()
|
||||
: null,
|
||||
SHA512 = hash == Hash.SHA512
|
||||
SHA512 = hash == HashType.SHA512
|
||||
? roms
|
||||
.Where(r => r != null)
|
||||
.Select(ConvertToSHA512)
|
||||
.ToArray()
|
||||
: null,
|
||||
SpamSum = hash == Hash.SpamSum
|
||||
SpamSum = hash == HashType.SpamSum
|
||||
? roms
|
||||
.Where(r => r != null)
|
||||
.Select(ConvertToSpamSum)
|
||||
|
||||
@@ -6,10 +6,67 @@ using SabreTools.IO;
|
||||
using SabreTools.Models.AACS;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class AACS : IStreamSerializer<MediaKeyBlock>
|
||||
public class AACS :
|
||||
IByteDeserializer<MediaKeyBlock>,
|
||||
IFileDeserializer<MediaKeyBlock>,
|
||||
IStreamDeserializer<MediaKeyBlock>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static MediaKeyBlock? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new AACS();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MediaKeyBlock? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static MediaKeyBlock? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new AACS();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MediaKeyBlock? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static MediaKeyBlock? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new AACS();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MediaKeyBlock? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -439,5 +496,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
39
SabreTools.Serialization/Deserializers/ArchiveDotOrg.cs
Normal file
39
SabreTools.Serialization/Deserializers/ArchiveDotOrg.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class ArchiveDotOrg :
|
||||
XmlFile<Models.ArchiveDotOrg.Files>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.ArchiveDotOrg.Files? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new ArchiveDotOrg();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.ArchiveDotOrg.Files? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new ArchiveDotOrg();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.ArchiveDotOrg.Files? DeserializeStream(System.IO.Stream? data)
|
||||
{
|
||||
var deserializer = new ArchiveDotOrg();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,75 @@ using SabreTools.IO.Readers;
|
||||
using SabreTools.Models.AttractMode;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class AttractMode : IStreamSerializer<MetadataFile>
|
||||
public class AttractMode :
|
||||
IByteDeserializer<MetadataFile>,
|
||||
IFileDeserializer<MetadataFile>,
|
||||
IStreamDeserializer<MetadataFile>
|
||||
{
|
||||
#region Constants
|
||||
|
||||
public const int HeaderWithoutRomnameCount = 17;
|
||||
|
||||
public const int HeaderWithRomnameCount = 22;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static MetadataFile? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new AttractMode();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static MetadataFile? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new AttractMode();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static MetadataFile? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new AttractMode();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -41,7 +106,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
// Parse the line into a row
|
||||
Row row;
|
||||
if (reader.Line.Count < Serialization.AttractMode.HeaderWithRomnameCount)
|
||||
if (reader.Line.Count < HeaderWithRomnameCount)
|
||||
{
|
||||
row = new Row
|
||||
{
|
||||
@@ -65,8 +130,8 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
|
||||
// If we have additional fields
|
||||
if (reader.Line.Count > Serialization.AttractMode.HeaderWithoutRomnameCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(Serialization.AttractMode.HeaderWithoutRomnameCount).ToArray();
|
||||
if (reader.Line.Count > HeaderWithoutRomnameCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(HeaderWithoutRomnameCount).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -92,8 +157,8 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
|
||||
// If we have additional fields
|
||||
if (reader.Line.Count > Serialization.AttractMode.HeaderWithRomnameCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(Serialization.AttractMode.HeaderWithRomnameCount).ToArray();
|
||||
if (reader.Line.Count > HeaderWithRomnameCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(HeaderWithRomnameCount).ToArray();
|
||||
}
|
||||
|
||||
rows.Add(row);
|
||||
@@ -103,5 +168,7 @@ namespace SabreTools.Serialization.Streams
|
||||
dat.Row = rows.ToArray();
|
||||
return dat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.BDPlus;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.BDPlus.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class BDPlus : IStreamSerializer<SVM>
|
||||
public class BDPlus :
|
||||
IByteDeserializer<SVM>,
|
||||
IFileDeserializer<SVM>,
|
||||
IStreamDeserializer<SVM>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static SVM? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new BDPlus();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SVM? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static SVM? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new BDPlus();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SVM? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static SVM? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new BDPlus();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SVM? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -62,5 +119,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return svm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.BFPK;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.BFPK.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class BFPK : IStreamSerializer<Archive>
|
||||
public class BFPK :
|
||||
IByteDeserializer<Archive>,
|
||||
IFileDeserializer<Archive>,
|
||||
IStreamDeserializer<Archive>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Archive? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new BFPK();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Archive? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new BFPK();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Archive? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new BFPK();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -118,5 +175,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return fileEntry;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,67 @@ using SabreTools.Models.BSP;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.BSP.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class BSP : IStreamSerializer<Models.BSP.File>
|
||||
public class BSP :
|
||||
IByteDeserializer<Models.BSP.File>,
|
||||
IFileDeserializer<Models.BSP.File>,
|
||||
IStreamDeserializer<Models.BSP.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.BSP.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new BSP();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.BSP.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.BSP.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new BSP();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.BSP.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.BSP.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new BSP();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.BSP.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -149,6 +206,8 @@ namespace SabreTools.Serialization.Streams
|
||||
for (int i = 0; i < textureHeader.TextureCount; i++)
|
||||
{
|
||||
offsets[i] = data.ReadUInt32();
|
||||
if (data.Position >= data.Length)
|
||||
break;
|
||||
}
|
||||
|
||||
textureHeader.Offsets = offsets;
|
||||
@@ -215,5 +274,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,67 @@ using SabreTools.Models.CFB;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.CFB.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class CFB : IStreamSerializer<Binary>
|
||||
public class CFB :
|
||||
IByteDeserializer<Binary>,
|
||||
IFileDeserializer<Binary>,
|
||||
IStreamDeserializer<Binary>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Binary? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new CFB();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Binary? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Binary? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new CFB();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Binary? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Binary? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new CFB();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Binary? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -361,5 +418,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return directoryEntry;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.IO;
|
||||
using SabreTools.Models.N3DS;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class CIA : IStreamSerializer<Models.N3DS.CIA>
|
||||
public class CIA :
|
||||
IByteDeserializer<Models.N3DS.CIA>,
|
||||
IFileDeserializer<Models.N3DS.CIA>,
|
||||
IStreamDeserializer<Models.N3DS.CIA>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.N3DS.CIA? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new CIA();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.N3DS.CIA? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.N3DS.CIA? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new CIA();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.N3DS.CIA? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.N3DS.CIA? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new CIA();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.N3DS.CIA? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -500,5 +557,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return metaData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
54
SabreTools.Serialization/Deserializers/Catalog.cs
Normal file
54
SabreTools.Serialization/Deserializers/Catalog.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class Catalog :
|
||||
JsonFile<Models.Xbox.Catalog>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.Xbox.Catalog? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new Catalog();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <remarks>Catalog.js file is encoded as UTF-16 LE</remarks>
|
||||
public override Models.Xbox.Catalog? Deserialize(byte[]? data, int offset)
|
||||
=> Deserialize(data, offset, new UnicodeEncoding());
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.Xbox.Catalog? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new Catalog();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <remarks>Catalog.js file is encoded as UTF-16 LE</remarks>
|
||||
public override Models.Xbox.Catalog? Deserialize(string? path)
|
||||
=> Deserialize(path, new UnicodeEncoding());
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.Xbox.Catalog? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new Catalog();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <remarks>Catalog.js file is encoded as UTF-16 LE</remarks>
|
||||
public override Models.Xbox.Catalog? Deserialize(Stream? data)
|
||||
=> Deserialize(data, new UnicodeEncoding());
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,78 @@ using SabreTools.IO.Readers;
|
||||
using SabreTools.Models.ClrMamePro;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class ClrMamePro : IStreamSerializer<MetadataFile>
|
||||
public class ClrMamePro :
|
||||
IByteDeserializer<MetadataFile>,
|
||||
IFileDeserializer<MetadataFile>,
|
||||
IStreamDeserializer<MetadataFile>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static MetadataFile? DeserializeBytes(byte[]? data, int offset, bool quotes = true)
|
||||
{
|
||||
var deserializer = new ClrMamePro();
|
||||
return deserializer.Deserialize(data, offset, quotes);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data) => Deserialize(data, true);
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset)
|
||||
=> Deserialize(data, offset, true);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset, bool quotes)
|
||||
{
|
||||
// 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
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream, quotes);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static MetadataFile? DeserializeFile(string? path, bool quotes = true)
|
||||
{
|
||||
var deserializer = new ClrMamePro();
|
||||
return deserializer.Deserialize(path, quotes);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
=> Deserialize(path, true);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path, bool quotes)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream, quotes);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static MetadataFile? DeserializeStream(Stream? data, bool quotes = true)
|
||||
{
|
||||
var deserializer = new ClrMamePro();
|
||||
return deserializer.Deserialize(data, quotes);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data)
|
||||
=> Deserialize(data, true);
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public MetadataFile? Deserialize(Stream? data, bool quotes)
|
||||
@@ -891,5 +957,7 @@ namespace SabreTools.Serialization.Streams
|
||||
driver.ADDITIONAL_ELEMENTS = itemAdditional.ToArray();
|
||||
return driver;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,67 @@ using SabreTools.IO;
|
||||
using SabreTools.Models.CueSheets;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class CueSheet : IStreamSerializer<Models.CueSheets.CueSheet>
|
||||
public class CueSheet :
|
||||
IByteDeserializer<Models.CueSheets.CueSheet>,
|
||||
IFileDeserializer<Models.CueSheets.CueSheet>,
|
||||
IStreamDeserializer<Models.CueSheets.CueSheet>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.CueSheets.CueSheet? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new CueSheet();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.CueSheets.CueSheet? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.CueSheets.CueSheet? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new CueSheet();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.CueSheets.CueSheet? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.CueSheets.CueSheet? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new CueSheet();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.CueSheets.CueSheet? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -513,26 +570,15 @@ namespace SabreTools.Serialization.Streams
|
||||
/// <returns>CueFileType, if possible</returns>
|
||||
private static CueFileType GetFileType(string? fileType)
|
||||
{
|
||||
switch (fileType?.ToLowerInvariant())
|
||||
return (fileType?.ToLowerInvariant()) switch
|
||||
{
|
||||
case "binary":
|
||||
return CueFileType.BINARY;
|
||||
|
||||
case "motorola":
|
||||
return CueFileType.MOTOROLA;
|
||||
|
||||
case "aiff":
|
||||
return CueFileType.AIFF;
|
||||
|
||||
case "wave":
|
||||
return CueFileType.WAVE;
|
||||
|
||||
case "mp3":
|
||||
return CueFileType.MP3;
|
||||
|
||||
default:
|
||||
return CueFileType.BINARY;
|
||||
}
|
||||
"binary" => CueFileType.BINARY,
|
||||
"motorola" => CueFileType.MOTOROLA,
|
||||
"aiff" => CueFileType.AIFF,
|
||||
"wave" => CueFileType.WAVE,
|
||||
"mp3" => CueFileType.MP3,
|
||||
_ => CueFileType.BINARY,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -542,35 +588,18 @@ namespace SabreTools.Serialization.Streams
|
||||
/// <returns>CueTrackDataType, if possible (default AUDIO)</returns>
|
||||
private static CueTrackDataType GetDataType(string? dataType)
|
||||
{
|
||||
switch (dataType?.ToLowerInvariant())
|
||||
return (dataType?.ToLowerInvariant()) switch
|
||||
{
|
||||
case "audio":
|
||||
return CueTrackDataType.AUDIO;
|
||||
|
||||
case "cdg":
|
||||
return CueTrackDataType.CDG;
|
||||
|
||||
case "mode1/2048":
|
||||
return CueTrackDataType.MODE1_2048;
|
||||
|
||||
case "mode1/2352":
|
||||
return CueTrackDataType.MODE1_2352;
|
||||
|
||||
case "mode2/2336":
|
||||
return CueTrackDataType.MODE2_2336;
|
||||
|
||||
case "mode2/2352":
|
||||
return CueTrackDataType.MODE2_2352;
|
||||
|
||||
case "cdi/2336":
|
||||
return CueTrackDataType.CDI_2336;
|
||||
|
||||
case "cdi/2352":
|
||||
return CueTrackDataType.CDI_2352;
|
||||
|
||||
default:
|
||||
return CueTrackDataType.AUDIO;
|
||||
}
|
||||
"audio" => CueTrackDataType.AUDIO,
|
||||
"cdg" => CueTrackDataType.CDG,
|
||||
"mode1/2048" => CueTrackDataType.MODE1_2048,
|
||||
"mode1/2352" => CueTrackDataType.MODE1_2352,
|
||||
"mode2/2336" => CueTrackDataType.MODE2_2336,
|
||||
"mode2/2352" => CueTrackDataType.MODE2_2352,
|
||||
"cdi/2336" => CueTrackDataType.CDI_2336,
|
||||
"cdi/2352" => CueTrackDataType.CDI_2352,
|
||||
_ => CueTrackDataType.AUDIO,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -618,5 +647,7 @@ namespace SabreTools.Serialization.Streams
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.IO.Readers;
|
||||
using SabreTools.Models.DosCenter;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class DosCenter : IStreamSerializer<MetadataFile>
|
||||
public class DosCenter :
|
||||
IByteDeserializer<MetadataFile>,
|
||||
IFileDeserializer<MetadataFile>,
|
||||
IStreamDeserializer<MetadataFile>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static MetadataFile? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new DosCenter();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static MetadataFile? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new DosCenter();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static MetadataFile? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new DosCenter();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -211,5 +268,7 @@ namespace SabreTools.Serialization.Streams
|
||||
file.ADDITIONAL_ELEMENTS = itemAdditional.ToArray();
|
||||
return file;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
122
SabreTools.Serialization/Deserializers/EverdriveSMDB.cs
Normal file
122
SabreTools.Serialization/Deserializers/EverdriveSMDB.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SabreTools.IO.Readers;
|
||||
using SabreTools.Models.EverdriveSMDB;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class EverdriveSMDB :
|
||||
IByteDeserializer<MetadataFile>,
|
||||
IFileDeserializer<MetadataFile>,
|
||||
IStreamDeserializer<MetadataFile>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static MetadataFile? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new EverdriveSMDB();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static MetadataFile? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new EverdriveSMDB();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static MetadataFile? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new EverdriveSMDB();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data)
|
||||
{
|
||||
// If the stream is null
|
||||
if (data == null)
|
||||
return default;
|
||||
|
||||
// Setup the reader and output
|
||||
var reader = new SeparatedValueReader(data, Encoding.UTF8)
|
||||
{
|
||||
Header = false,
|
||||
Separator = '\t',
|
||||
VerifyFieldCount = false,
|
||||
};
|
||||
var dat = new MetadataFile();
|
||||
|
||||
// Loop through the rows and parse out values
|
||||
var rows = new List<Row>();
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
// If we have no next line
|
||||
if (!reader.ReadNextLine() || reader.Line == null)
|
||||
break;
|
||||
|
||||
// Parse the line into a row
|
||||
var row = new Row
|
||||
{
|
||||
SHA256 = reader.Line[0],
|
||||
Name = reader.Line[1],
|
||||
SHA1 = reader.Line[2],
|
||||
MD5 = reader.Line[3],
|
||||
CRC32 = reader.Line[4],
|
||||
};
|
||||
|
||||
// If we have the size field
|
||||
if (reader.Line.Count > 5)
|
||||
row.Size = reader.Line[5];
|
||||
|
||||
// If we have additional fields
|
||||
if (reader.Line.Count > 6)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(5).ToArray();
|
||||
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
// Assign the rows to the Dat and return
|
||||
dat.Row = rows.ToArray();
|
||||
return dat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.IO;
|
||||
using SabreTools.Models.GCF;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class GCF : IStreamSerializer<Models.GCF.File>
|
||||
public class GCF :
|
||||
IByteDeserializer<Models.GCF.File>,
|
||||
IFileDeserializer<Models.GCF.File>,
|
||||
IStreamDeserializer<Models.GCF.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.GCF.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new GCF();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.GCF.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.GCF.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new GCF();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.GCF.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.GCF.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new GCF();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.GCF.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -740,5 +797,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return dataBlockHeader;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,85 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SabreTools.Hashing;
|
||||
using SabreTools.Models.Hashfile;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class Hashfile : IStreamSerializer<Models.Hashfile.Hashfile>
|
||||
public class Hashfile :
|
||||
IByteDeserializer<Models.Hashfile.Hashfile>,
|
||||
IFileDeserializer<Models.Hashfile.Hashfile>,
|
||||
IStreamDeserializer<Models.Hashfile.Hashfile>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.Hashfile.Hashfile? DeserializeBytes(byte[]? data, int offset, HashType hash = HashType.CRC32)
|
||||
{
|
||||
var deserializer = new Hashfile();
|
||||
return deserializer.Deserialize(data, offset, hash);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.Hashfile.Hashfile? Deserialize(Stream? data) => Deserialize(data, Hash.CRC);
|
||||
public Models.Hashfile.Hashfile? Deserialize(byte[]? data, int offset)
|
||||
=> Deserialize(data, offset, HashType.CRC32);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.Hashfile.Hashfile? Deserialize(byte[]? data, int offset, HashType hash)
|
||||
{
|
||||
// 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
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream, hash);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.Hashfile.Hashfile? DeserializeFile(string? path, HashType hash = HashType.CRC32)
|
||||
{
|
||||
var deserializer = new Hashfile();
|
||||
return deserializer.Deserialize(path, hash);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.Hashfile.Hashfile? Deserialize(string? path)
|
||||
=> Deserialize(path, HashType.CRC32);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.Hashfile.Hashfile? Deserialize(string? path, HashType hash)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream, hash);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.Hashfile.Hashfile? DeserializeStream(Stream? data, HashType hash = HashType.CRC32)
|
||||
{
|
||||
var deserializer = new Hashfile();
|
||||
return deserializer.Deserialize(data, hash);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.Hashfile.Hashfile? Deserialize(Stream? data)
|
||||
=> Deserialize(data, HashType.CRC32);
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? Deserialize(Stream? data, Hash hash)
|
||||
public Models.Hashfile.Hashfile? Deserialize(Stream? data, HashType hash)
|
||||
{
|
||||
// If the stream is null
|
||||
if (data == null)
|
||||
@@ -41,7 +108,11 @@ namespace SabreTools.Serialization.Streams
|
||||
// Parse the line into a hash
|
||||
switch (hash)
|
||||
{
|
||||
case Hash.CRC:
|
||||
case HashType.CRC32:
|
||||
case HashType.CRC32_ISO:
|
||||
case HashType.CRC32_Naive:
|
||||
case HashType.CRC32_Optimized:
|
||||
case HashType.CRC32_Parallel:
|
||||
var sfv = new SFV
|
||||
{
|
||||
#if NETFRAMEWORK
|
||||
@@ -54,7 +125,7 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
hashes.Add(sfv);
|
||||
break;
|
||||
case Hash.MD5:
|
||||
case HashType.MD5:
|
||||
var md5 = new MD5
|
||||
{
|
||||
Hash = lineParts[0],
|
||||
@@ -66,7 +137,7 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
hashes.Add(md5);
|
||||
break;
|
||||
case Hash.SHA1:
|
||||
case HashType.SHA1:
|
||||
var sha1 = new SHA1
|
||||
{
|
||||
Hash = lineParts[0],
|
||||
@@ -78,7 +149,7 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
hashes.Add(sha1);
|
||||
break;
|
||||
case Hash.SHA256:
|
||||
case HashType.SHA256:
|
||||
var sha256 = new SHA256
|
||||
{
|
||||
Hash = lineParts[0],
|
||||
@@ -90,7 +161,7 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
hashes.Add(sha256);
|
||||
break;
|
||||
case Hash.SHA384:
|
||||
case HashType.SHA384:
|
||||
var sha384 = new SHA384
|
||||
{
|
||||
Hash = lineParts[0],
|
||||
@@ -102,7 +173,7 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
hashes.Add(sha384);
|
||||
break;
|
||||
case Hash.SHA512:
|
||||
case HashType.SHA512:
|
||||
var sha512 = new SHA512
|
||||
{
|
||||
Hash = lineParts[0],
|
||||
@@ -114,7 +185,7 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
hashes.Add(sha512);
|
||||
break;
|
||||
case Hash.SpamSum:
|
||||
case HashType.SpamSum:
|
||||
var spamSum = new SpamSum
|
||||
{
|
||||
Hash = lineParts[0],
|
||||
@@ -132,30 +203,36 @@ namespace SabreTools.Serialization.Streams
|
||||
// Assign the hashes to the hashfile and return
|
||||
switch (hash)
|
||||
{
|
||||
case Hash.CRC:
|
||||
case HashType.CRC32:
|
||||
case HashType.CRC32_ISO:
|
||||
case HashType.CRC32_Naive:
|
||||
case HashType.CRC32_Optimized:
|
||||
case HashType.CRC32_Parallel:
|
||||
dat.SFV = hashes.Cast<SFV>().ToArray();
|
||||
break;
|
||||
case Hash.MD5:
|
||||
case HashType.MD5:
|
||||
dat.MD5 = hashes.Cast<MD5>().ToArray();
|
||||
break;
|
||||
case Hash.SHA1:
|
||||
case HashType.SHA1:
|
||||
dat.SHA1 = hashes.Cast<SHA1>().ToArray();
|
||||
break;
|
||||
case Hash.SHA256:
|
||||
case HashType.SHA256:
|
||||
dat.SHA256 = hashes.Cast<SHA256>().ToArray();
|
||||
break;
|
||||
case Hash.SHA384:
|
||||
case HashType.SHA384:
|
||||
dat.SHA384 = hashes.Cast<SHA384>().ToArray();
|
||||
break;
|
||||
case Hash.SHA512:
|
||||
case HashType.SHA512:
|
||||
dat.SHA512 = hashes.Cast<SHA512>().ToArray();
|
||||
break;
|
||||
case Hash.SpamSum:
|
||||
case HashType.SpamSum:
|
||||
dat.SpamSum = hashes.Cast<SpamSum>().ToArray();
|
||||
break;
|
||||
}
|
||||
dat.ADDITIONAL_ELEMENTS = [.. additional];
|
||||
return dat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,69 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SabreTools.IO;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class IRD : IStreamSerializer<Models.IRD.File>
|
||||
public class IRD :
|
||||
IByteDeserializer<Models.IRD.File>,
|
||||
IFileDeserializer<Models.IRD.File>,
|
||||
IStreamDeserializer<Models.IRD.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.IRD.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new IRD();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.IRD.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.IRD.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new IRD();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.IRD.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.IRD.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new IRD();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.IRD.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -111,5 +167,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return ird;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,68 @@ using SabreTools.Models.InstallShieldCabinet;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.InstallShieldCabinet.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
// TODO: Add multi-cabinet reading
|
||||
public partial class InstallShieldCabinet : IStreamSerializer<Cabinet>
|
||||
public class InstallShieldCabinet :
|
||||
IByteDeserializer<Cabinet>,
|
||||
IFileDeserializer<Cabinet>,
|
||||
IStreamDeserializer<Cabinet>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Cabinet? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new InstallShieldCabinet();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cabinet? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Cabinet? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new InstallShieldCabinet();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cabinet? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Cabinet? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new InstallShieldCabinet();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cabinet? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -776,5 +833,7 @@ namespace SabreTools.Serialization.Streams
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
99
SabreTools.Serialization/Deserializers/JsonFile.cs
Normal file
99
SabreTools.Serialization/Deserializers/JsonFile.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for other JSON serializers
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class JsonFile<T> :
|
||||
IByteDeserializer<T>,
|
||||
IFileDeserializer<T>,
|
||||
IStreamDeserializer<T>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual T? Deserialize(byte[]? data, int offset)
|
||||
=> Deserialize(data, offset, new UTF8Encoding(false));
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize a byte array into <typeparamref name="T"/>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of object to deserialize to</typeparam>
|
||||
/// <param name="data">Byte array to parse</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <param name="encoding">Encoding to parse text as</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
public T? Deserialize(byte[]? data, int offset, Encoding encoding)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return default;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return default;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return Deserialize(dataStream, encoding);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual T? Deserialize(string? path)
|
||||
=> Deserialize(path, new UTF8Encoding(false));
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize a file into <typeparamref name="T"/>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of object to deserialize to</typeparam>
|
||||
/// <param name="path">Path to deserialize from</param>
|
||||
/// <param name="encoding">Encoding to parse text as</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
public T? Deserialize(string? path, Encoding encoding)
|
||||
{
|
||||
using var data = PathProcessor.OpenStream(path);
|
||||
return Deserialize(data, encoding);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual T? Deserialize(Stream? data)
|
||||
=> Deserialize(data, new UTF8Encoding(false));
|
||||
|
||||
/// <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>
|
||||
/// <param name="encoding">Text encoding to use</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
public T? Deserialize(Stream? data, Encoding encoding)
|
||||
{
|
||||
// If the stream is null
|
||||
if (data == null)
|
||||
return default;
|
||||
|
||||
// Setup the serializer and the reader
|
||||
var serializer = JsonSerializer.Create();
|
||||
var streamReader = new StreamReader(data, encoding);
|
||||
var jsonReader = new JsonTextReader(streamReader);
|
||||
|
||||
// Perform the deserialization and return
|
||||
return serializer.Deserialize<T>(jsonReader);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,67 @@ using SabreTools.Models.LinearExecutable;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.LinearExecutable.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class LinearExecutable : IStreamSerializer<Executable>
|
||||
public class LinearExecutable :
|
||||
IByteDeserializer<Executable>,
|
||||
IFileDeserializer<Executable>,
|
||||
IStreamDeserializer<Executable>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Executable? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new LinearExecutable();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Executable? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new LinearExecutable();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Executable? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new LinearExecutable();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -1002,5 +1059,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return debugInformation;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using System.Text;
|
||||
using SabreTools.Models.Listrom;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class Listrom : IStreamSerializer<MetadataFile>
|
||||
public class Listrom :
|
||||
IByteDeserializer<MetadataFile>,
|
||||
IFileDeserializer<MetadataFile>,
|
||||
IStreamDeserializer<MetadataFile>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static MetadataFile? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new Listrom();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static MetadataFile? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new Listrom();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static MetadataFile? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new Listrom();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -238,5 +295,7 @@ namespace SabreTools.Serialization.Streams
|
||||
dat.ADDITIONAL_ELEMENTS = additional.ToArray();
|
||||
return dat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
39
SabreTools.Serialization/Deserializers/Listxml.cs
Normal file
39
SabreTools.Serialization/Deserializers/Listxml.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class Listxml :
|
||||
XmlFile<Models.Listxml.Mame>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.Listxml.Mame? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new Listxml();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.Listxml.Mame? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new Listxml();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.Listxml.Mame? DeserializeStream(System.IO.Stream? data)
|
||||
{
|
||||
var deserializer = new Listxml();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
39
SabreTools.Serialization/Deserializers/Logiqx.cs
Normal file
39
SabreTools.Serialization/Deserializers/Logiqx.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class Logiqx :
|
||||
XmlFile<Models.Logiqx.Datafile>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.Logiqx.Datafile? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new Logiqx();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.Logiqx.Datafile? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new Logiqx();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.Logiqx.Datafile? DeserializeStream(System.IO.Stream? data)
|
||||
{
|
||||
var deserializer = new Logiqx();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
39
SabreTools.Serialization/Deserializers/M1.cs
Normal file
39
SabreTools.Serialization/Deserializers/M1.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class M1 :
|
||||
XmlFile<Models.Listxml.M1>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.Listxml.M1? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new M1();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.Listxml.M1? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new M1();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.Listxml.M1? DeserializeStream(System.IO.Stream? data)
|
||||
{
|
||||
var deserializer = new M1();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.MSDOS;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.MSDOS.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class MSDOS : IStreamSerializer<Executable>
|
||||
public class MSDOS :
|
||||
IByteDeserializer<Executable>,
|
||||
IFileDeserializer<Executable>,
|
||||
IStreamDeserializer<Executable>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Executable? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new MSDOS();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Executable? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new MSDOS();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Executable? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new MSDOS();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -142,5 +199,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return relocationTable;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,68 @@ using SabreTools.Models.MicrosoftCabinet;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.MicrosoftCabinet.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
// TODO: Add multi-cabinet reading
|
||||
public partial class MicrosoftCabinet : IStreamSerializer<Cabinet>
|
||||
public class MicrosoftCabinet :
|
||||
IByteDeserializer<Cabinet>,
|
||||
IFileDeserializer<Cabinet>,
|
||||
IStreamDeserializer<Cabinet>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Cabinet? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new MicrosoftCabinet();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cabinet? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Cabinet? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new MicrosoftCabinet();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cabinet? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Cabinet? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new MicrosoftCabinet();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cabinet? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -241,5 +298,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,67 @@ using SabreTools.Models.MoPaQ;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.MoPaQ.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class MoPaQ : IStreamSerializer<Archive>
|
||||
public class MoPaQ :
|
||||
IByteDeserializer<Archive>,
|
||||
IFileDeserializer<Archive>,
|
||||
IStreamDeserializer<Archive>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Archive? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new MoPaQ();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Archive? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new MoPaQ();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Archive? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new MoPaQ();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -628,5 +685,7 @@ namespace SabreTools.Serialization.Streams
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,67 @@ using SabreTools.Models.N3DS;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.N3DS.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class N3DS : IStreamSerializer<Cart>
|
||||
public class N3DS :
|
||||
IByteDeserializer<Cart>,
|
||||
IFileDeserializer<Cart>,
|
||||
IStreamDeserializer<Cart>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Cart? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new N3DS();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cart? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Cart? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new N3DS();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cart? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Cart? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new N3DS();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cart? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -708,5 +765,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return romFSHeader;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.IO;
|
||||
using SabreTools.Models.NCF;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class NCF : IStreamSerializer<Models.NCF.File>
|
||||
public class NCF :
|
||||
IByteDeserializer<Models.NCF.File>,
|
||||
IFileDeserializer<Models.NCF.File>,
|
||||
IStreamDeserializer<Models.NCF.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.NCF.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new NCF();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.NCF.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.NCF.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new NCF();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.NCF.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.NCF.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new NCF();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.NCF.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -509,5 +566,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return checksumEntry;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,67 @@ using SabreTools.Models.NewExecutable;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.NewExecutable.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class NewExecutable : IStreamSerializer<Executable>
|
||||
public class NewExecutable :
|
||||
IByteDeserializer<Executable>,
|
||||
IFileDeserializer<Executable>,
|
||||
IStreamDeserializer<Executable>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Executable? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new NewExecutable();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Executable? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new NewExecutable();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Executable? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new NewExecutable();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -477,5 +534,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return [.. residentNameTable];
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.IO;
|
||||
using SabreTools.Models.Nitro;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class Nitro : IStreamSerializer<Cart>
|
||||
public class Nitro :
|
||||
IByteDeserializer<Cart>,
|
||||
IFileDeserializer<Cart>,
|
||||
IStreamDeserializer<Cart>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Cart? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new Nitro();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cart? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Cart? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new Nitro();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cart? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Cart? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new Nitro();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Cart? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -360,5 +417,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
39
SabreTools.Serialization/Deserializers/OfflineList.cs
Normal file
39
SabreTools.Serialization/Deserializers/OfflineList.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class OfflineList :
|
||||
XmlFile<Models.OfflineList.Dat>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.OfflineList.Dat? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new OfflineList();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.OfflineList.Dat? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new OfflineList();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.OfflineList.Dat? DeserializeStream(System.IO.Stream? data)
|
||||
{
|
||||
var deserializer = new OfflineList();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
39
SabreTools.Serialization/Deserializers/OpenMSX.cs
Normal file
39
SabreTools.Serialization/Deserializers/OpenMSX.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class OpenMSX :
|
||||
XmlFile<Models.OpenMSX.SoftwareDb>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.OpenMSX.SoftwareDb? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new OpenMSX();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.OpenMSX.SoftwareDb? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new OpenMSX();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.OpenMSX.SoftwareDb? DeserializeStream(System.IO.Stream? data)
|
||||
{
|
||||
var deserializer = new OpenMSX();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.PAK;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.PAK.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class PAK : IStreamSerializer<Models.PAK.File>
|
||||
public class PAK :
|
||||
IByteDeserializer<Models.PAK.File>,
|
||||
IFileDeserializer<Models.PAK.File>,
|
||||
IStreamDeserializer<Models.PAK.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.PAK.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new PAK();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.PAK.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.PAK.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new PAK();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.PAK.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.PAK.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new PAK();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.PAK.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -105,5 +162,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return directoryItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.PFF;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.PFF.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class PFF : IStreamSerializer<Archive>
|
||||
public class PFF :
|
||||
IByteDeserializer<Archive>,
|
||||
IFileDeserializer<Archive>,
|
||||
IStreamDeserializer<Archive>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Archive? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new PFF();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Archive? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new PFF();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Archive? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new PFF();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -180,5 +237,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,67 @@ using SabreTools.Models.PIC;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.PIC.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class PIC : IStreamSerializer<DiscInformation>
|
||||
public class PIC :
|
||||
IByteDeserializer<DiscInformation>,
|
||||
IFileDeserializer<DiscInformation>,
|
||||
IStreamDeserializer<DiscInformation>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static DiscInformation? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new PIC();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DiscInformation? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static DiscInformation? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new PIC();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DiscInformation? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static DiscInformation? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new PIC();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DiscInformation? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -176,5 +233,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return trailer;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,70 @@ using SabreTools.Models.PlayJ;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.PlayJ.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class PlayJAudio : IStreamSerializer<AudioFile>
|
||||
public class PlayJAudio :
|
||||
IByteDeserializer<AudioFile>,
|
||||
IFileDeserializer<AudioFile>,
|
||||
IStreamDeserializer<AudioFile>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static AudioFile? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new PlayJAudio();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public AudioFile? Deserialize(Stream? data) => Deserialize(data, 0);
|
||||
public AudioFile? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static AudioFile? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new PlayJAudio();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public AudioFile? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static AudioFile? DeserializeStream(Stream? data, long adjust = 0)
|
||||
{
|
||||
var deserializer = new PlayJAudio();
|
||||
return deserializer.Deserialize(data, adjust);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public AudioFile? Deserialize(Stream? data)
|
||||
=> Deserialize(data, 0);
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
/// <param name="adjust">Offset to adjust all seeking by</param>
|
||||
@@ -339,5 +397,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return dataFile;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,67 @@ using SabreTools.IO;
|
||||
using SabreTools.Models.PlayJ;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class PlayJPlaylist : IStreamSerializer<Playlist>
|
||||
public class PlayJPlaylist :
|
||||
IByteDeserializer<Playlist>,
|
||||
IFileDeserializer<Playlist>,
|
||||
IStreamDeserializer<Playlist>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Playlist? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new PlayJPlaylist();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Playlist? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Playlist? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new PlayJPlaylist();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Playlist? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Playlist? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new PlayJPlaylist();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Playlist? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -45,7 +102,7 @@ namespace SabreTools.Serialization.Streams
|
||||
for (int i = 0; i < playlist.AudioFiles.Length; i++)
|
||||
{
|
||||
long currentOffset = data.Position;
|
||||
var entryHeader = new PlayJAudio().Deserialize(data, currentOffset);
|
||||
var entryHeader = PlayJAudio.DeserializeStream(data, currentOffset);
|
||||
if (entryHeader == null)
|
||||
return null;
|
||||
|
||||
@@ -72,5 +129,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return playlistHeader;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,67 @@ using SabreTools.Models.PortableExecutable;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.PortableExecutable.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class PortableExecutable : IStreamSerializer<Executable>
|
||||
public class PortableExecutable :
|
||||
IByteDeserializer<Executable>,
|
||||
IFileDeserializer<Executable>,
|
||||
IStreamDeserializer<Executable>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Executable? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new PortableExecutable();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Executable? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new PortableExecutable();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Executable? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new PortableExecutable();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Executable? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -1330,5 +1387,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return resourceDirectoryTable;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.Quantum;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.Quantum.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class Quantum : IStreamSerializer<Archive>
|
||||
public class Quantum :
|
||||
IByteDeserializer<Archive>,
|
||||
IFileDeserializer<Archive>,
|
||||
IStreamDeserializer<Archive>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Archive? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new Quantum();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Archive? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new Quantum();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Archive? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new Quantum();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Archive? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -153,5 +210,7 @@ namespace SabreTools.Serialization.Streams
|
||||
byte b1 = data.ReadByteValue();
|
||||
return (b0 << 8) | b1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,67 @@ using SabreTools.IO.Readers;
|
||||
using SabreTools.Models.RomCenter;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class RomCenter : IStreamSerializer<MetadataFile>
|
||||
public class RomCenter :
|
||||
IByteDeserializer<MetadataFile>,
|
||||
IFileDeserializer<MetadataFile>,
|
||||
IStreamDeserializer<MetadataFile>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static MetadataFile? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new RomCenter();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static MetadataFile? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new RomCenter();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static MetadataFile? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new RomCenter();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -210,5 +267,7 @@ namespace SabreTools.Serialization.Streams
|
||||
}
|
||||
return dat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,67 @@ using SabreTools.Models.SGA;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.SGA.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class SGA : IStreamSerializer<Models.SGA.File>
|
||||
public class SGA :
|
||||
IByteDeserializer<Models.SGA.File>,
|
||||
IFileDeserializer<Models.SGA.File>,
|
||||
IStreamDeserializer<Models.SGA.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.SGA.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new SGA();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.SGA.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.SGA.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new SGA();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.SGA.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.SGA.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new SGA();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.SGA.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -725,5 +782,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return file7;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,86 @@ using SabreTools.IO.Readers;
|
||||
using SabreTools.Models.SeparatedValue;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class SeparatedValue : IStreamSerializer<MetadataFile>
|
||||
public class SeparatedValue :
|
||||
IByteDeserializer<MetadataFile>,
|
||||
IFileDeserializer<MetadataFile>,
|
||||
IStreamDeserializer<MetadataFile>
|
||||
{
|
||||
#region Constants
|
||||
|
||||
public const int HeaderWithoutExtendedHashesCount = 14;
|
||||
|
||||
public const int HeaderWithExtendedHashesCount = 17;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static MetadataFile? DeserializeBytes(byte[]? data, int offset, char delim)
|
||||
{
|
||||
var deserializer = new SeparatedValue();
|
||||
return deserializer.Deserialize(data, offset, delim);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data) => Deserialize(data, ',');
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset)
|
||||
=> Deserialize(data, offset, ',');
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(byte[]? data, int offset, char delim)
|
||||
{
|
||||
// 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
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream, delim);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static MetadataFile? DeserializeFile(string? path, char delim = ',')
|
||||
{
|
||||
var deserializer = new SeparatedValue();
|
||||
return deserializer.Deserialize(path, delim);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
=> Deserialize(path, ',');
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path, char delim)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream, delim);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static MetadataFile? DeserializeStream(Stream? data, char delim = ',')
|
||||
{
|
||||
var deserializer = new SeparatedValue();
|
||||
return deserializer.Deserialize(data, delim);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(Stream? data)
|
||||
=> Deserialize(data, ',');
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public MetadataFile? Deserialize(Stream? data, char delim)
|
||||
@@ -45,7 +119,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
// Parse the line into a row
|
||||
Row? row = null;
|
||||
if (reader.Line.Count < Serialization.SeparatedValue.HeaderWithExtendedHashesCount)
|
||||
if (reader.Line.Count < HeaderWithExtendedHashesCount)
|
||||
{
|
||||
row = new Row
|
||||
{
|
||||
@@ -66,8 +140,8 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
|
||||
// If we have additional fields
|
||||
if (reader.Line.Count > Serialization.SeparatedValue.HeaderWithoutExtendedHashesCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(Serialization.SeparatedValue.HeaderWithoutExtendedHashesCount).ToArray();
|
||||
if (reader.Line.Count > HeaderWithoutExtendedHashesCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(HeaderWithoutExtendedHashesCount).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -93,8 +167,8 @@ namespace SabreTools.Serialization.Streams
|
||||
};
|
||||
|
||||
// If we have additional fields
|
||||
if (reader.Line.Count > Serialization.SeparatedValue.HeaderWithExtendedHashesCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(Serialization.SeparatedValue.HeaderWithExtendedHashesCount).ToArray();
|
||||
if (reader.Line.Count > HeaderWithExtendedHashesCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(HeaderWithExtendedHashesCount).ToArray();
|
||||
}
|
||||
rows.Add(row);
|
||||
}
|
||||
@@ -103,5 +177,7 @@ namespace SabreTools.Serialization.Streams
|
||||
dat.Row = rows.ToArray();
|
||||
return dat;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
39
SabreTools.Serialization/Deserializers/SoftwareList.cs
Normal file
39
SabreTools.Serialization/Deserializers/SoftwareList.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class SoftwareList :
|
||||
XmlFile<Models.SoftwareList.SoftwareList>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.SoftwareList.SoftwareList? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new SoftwareList();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.SoftwareList.SoftwareList? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new SoftwareList();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.SoftwareList.SoftwareList? DeserializeStream(System.IO.Stream? data)
|
||||
{
|
||||
var deserializer = new SoftwareList();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.VBSP;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.VBSP.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class VBSP : IStreamSerializer<Models.VBSP.File>
|
||||
public class VBSP :
|
||||
IByteDeserializer<Models.VBSP.File>,
|
||||
IFileDeserializer<Models.VBSP.File>,
|
||||
IStreamDeserializer<Models.VBSP.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.VBSP.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new VBSP();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.VBSP.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.VBSP.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new VBSP();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.VBSP.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.VBSP.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new VBSP();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.VBSP.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -108,5 +165,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return lump;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,67 @@ using SabreTools.Models.VPK;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.VPK.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class VPK : IStreamSerializer<Models.VPK.File>
|
||||
public class VPK :
|
||||
IByteDeserializer<Models.VPK.File>,
|
||||
IFileDeserializer<Models.VPK.File>,
|
||||
IStreamDeserializer<Models.VPK.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.VPK.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new VPK();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.VPK.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.VPK.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new VPK();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.VPK.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.VPK.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new VPK();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.VPK.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -282,5 +339,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return directoryEntry;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.WAD;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.WAD.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class WAD : IStreamSerializer<Models.WAD.File>
|
||||
public class WAD :
|
||||
IByteDeserializer<Models.WAD.File>,
|
||||
IFileDeserializer<Models.WAD.File>,
|
||||
IStreamDeserializer<Models.WAD.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.WAD.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new WAD();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.WAD.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.WAD.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new WAD();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.WAD.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.WAD.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new WAD();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.WAD.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -241,5 +298,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return lumpInfo;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,19 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Strings
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class XMID : IStringSerializer<Models.Xbox.XMID>
|
||||
public partial class XMID :
|
||||
IStringDeserializer<Models.Xbox.XMID>
|
||||
{
|
||||
#region IStringDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStringDeserializer.Deserialize(string?)"/>
|
||||
public static Models.Xbox.XMID? DeserializeString(string? str)
|
||||
{
|
||||
var deserializer = new XMID();
|
||||
return deserializer.Deserialize(str);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.Xbox.XMID? Deserialize(string? str)
|
||||
{
|
||||
@@ -36,5 +46,7 @@ namespace SabreTools.Serialization.Strings
|
||||
|
||||
return xmid;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,67 @@ using SabreTools.Models.XZP;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using static SabreTools.Models.XZP.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class XZP : IStreamSerializer<Models.XZP.File>
|
||||
public class XZP :
|
||||
IByteDeserializer<Models.XZP.File>,
|
||||
IFileDeserializer<Models.XZP.File>,
|
||||
IStreamDeserializer<Models.XZP.File>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc cref="IByteDeserializer.Deserialize(byte[]?, int)"/>
|
||||
public static Models.XZP.File? DeserializeBytes(byte[]? data, int offset)
|
||||
{
|
||||
var deserializer = new XZP();
|
||||
return deserializer.Deserialize(data, offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.XZP.File? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return DeserializeStream(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
public static Models.XZP.File? DeserializeFile(string? path)
|
||||
{
|
||||
var deserializer = new XZP();
|
||||
return deserializer.Deserialize(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.XZP.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return DeserializeStream(stream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStreamDeserializer.Deserialize(Stream?)"/>
|
||||
public static Models.XZP.File? DeserializeStream(Stream? data)
|
||||
{
|
||||
var deserializer = new XZP();
|
||||
return deserializer.Deserialize(data);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.XZP.File? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -244,5 +301,7 @@ namespace SabreTools.Serialization.Streams
|
||||
|
||||
return footer;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,19 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Strings
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public partial class XeMID : IStringSerializer<Models.Xbox.XeMID>
|
||||
public partial class XeMID :
|
||||
IStringDeserializer<Models.Xbox.XeMID>
|
||||
{
|
||||
#region IStringDeserializer
|
||||
|
||||
/// <inheritdoc cref="IStringDeserializer.Deserialize(string?)"/>
|
||||
public static Models.Xbox.XeMID? DeserializeString(string? str)
|
||||
{
|
||||
var deserializer = new XeMID();
|
||||
return deserializer.Deserialize(str);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Models.Xbox.XeMID? Deserialize(string? str)
|
||||
{
|
||||
@@ -60,5 +70,7 @@ namespace SabreTools.Serialization.Strings
|
||||
|
||||
return xemid;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,50 @@ using System.Xml.Schema;
|
||||
using System.Xml.Serialization;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Streams
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for other XML serializers
|
||||
/// Base class for other XML deserializers
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public partial class XmlFile<T> : IStreamSerializer<T>
|
||||
public class XmlFile<T> :
|
||||
IByteDeserializer<T>,
|
||||
IFileDeserializer<T>,
|
||||
IStreamDeserializer<T>
|
||||
{
|
||||
#region IByteDeserializer
|
||||
|
||||
/// <inheritdoc/>
|
||||
public T? Deserialize(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
return default;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return default;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return Deserialize(dataStream);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc/>
|
||||
public T? Deserialize(string? path)
|
||||
{
|
||||
using var data = PathProcessor.OpenStream(path);
|
||||
return Deserialize(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStreamDeserializer
|
||||
|
||||
/// <inheritdoc/>
|
||||
public T? Deserialize(Stream? data)
|
||||
{
|
||||
@@ -36,5 +72,7 @@ namespace SabreTools.Serialization.Streams
|
||||
// Perform the deserialization and return
|
||||
return (T?)serializer.Deserialize(xmlReader);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace SabreTools.Serialization
|
||||
{
|
||||
public enum Hash
|
||||
{
|
||||
CRC,
|
||||
MD5,
|
||||
SHA1,
|
||||
SHA256,
|
||||
SHA384,
|
||||
SHA512,
|
||||
SpamSum,
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,65 @@ namespace SabreTools.Serialization
|
||||
return -1;
|
||||
}
|
||||
|
||||
#region Debug
|
||||
|
||||
/// <summary>
|
||||
/// Read debug data as an NB10 Program Database
|
||||
/// </summary>
|
||||
/// <param name="data">Data to parse into a database</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>A filled NB10 Program Database on success, null on error</returns>
|
||||
public static NB10ProgramDatabase? AsNB10ProgramDatabase(this byte[] data, ref int offset)
|
||||
{
|
||||
// If we have data that's invalid, we can't do anything
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
var nb10ProgramDatabase = new NB10ProgramDatabase();
|
||||
|
||||
nb10ProgramDatabase.Signature = data.ReadUInt32(ref offset);
|
||||
if (nb10ProgramDatabase.Signature != 0x3031424E)
|
||||
return null;
|
||||
|
||||
nb10ProgramDatabase.Offset = data.ReadUInt32(ref offset);
|
||||
nb10ProgramDatabase.Timestamp = data.ReadUInt32(ref offset);
|
||||
nb10ProgramDatabase.Age = data.ReadUInt32(ref offset);
|
||||
nb10ProgramDatabase.PdbFileName = data.ReadString(ref offset, Encoding.ASCII); // TODO: Actually null-terminated UTF-8?
|
||||
|
||||
return nb10ProgramDatabase;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read debug data as an RSDS Program Database
|
||||
/// </summary>
|
||||
/// <param name="data">Data to parse into a database</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>A filled RSDS Program Database on success, null on error</returns>
|
||||
public static RSDSProgramDatabase? AsRSDSProgramDatabase(this byte[]? data, ref int offset)
|
||||
{
|
||||
// If we have data that's invalid, we can't do anything
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
var rsdsProgramDatabase = new RSDSProgramDatabase();
|
||||
|
||||
rsdsProgramDatabase.Signature = data.ReadUInt32(ref offset);
|
||||
if (rsdsProgramDatabase.Signature != 0x53445352)
|
||||
return null;
|
||||
|
||||
var guid = data.ReadBytes(ref offset, 0x10);
|
||||
if (guid != null)
|
||||
rsdsProgramDatabase.GUID = new Guid(guid);
|
||||
rsdsProgramDatabase.Age = data.ReadUInt32(ref offset);
|
||||
rsdsProgramDatabase.PathAndFileName = data.ReadString(ref offset, Encoding.ASCII); // TODO: Actually null-terminated UTF-8
|
||||
|
||||
return rsdsProgramDatabase;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overlay
|
||||
|
||||
/// <summary>
|
||||
/// Read overlay data as a SecuROM AddD overlay data
|
||||
/// </summary>
|
||||
@@ -153,61 +212,6 @@ namespace SabreTools.Serialization
|
||||
return addD;
|
||||
}
|
||||
|
||||
#region Debug
|
||||
|
||||
/// <summary>
|
||||
/// Read debug data as an NB10 Program Database
|
||||
/// </summary>
|
||||
/// <param name="data">Data to parse into a database</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>A filled NB10 Program Database on success, null on error</returns>
|
||||
public static NB10ProgramDatabase? AsNB10ProgramDatabase(this byte[] data, ref int offset)
|
||||
{
|
||||
// If we have data that's invalid, we can't do anything
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
var nb10ProgramDatabase = new NB10ProgramDatabase();
|
||||
|
||||
nb10ProgramDatabase.Signature = data.ReadUInt32(ref offset);
|
||||
if (nb10ProgramDatabase.Signature != 0x3031424E)
|
||||
return null;
|
||||
|
||||
nb10ProgramDatabase.Offset = data.ReadUInt32(ref offset);
|
||||
nb10ProgramDatabase.Timestamp = data.ReadUInt32(ref offset);
|
||||
nb10ProgramDatabase.Age = data.ReadUInt32(ref offset);
|
||||
nb10ProgramDatabase.PdbFileName = data.ReadString(ref offset, Encoding.ASCII); // TODO: Actually null-terminated UTF-8?
|
||||
|
||||
return nb10ProgramDatabase;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read debug data as an RSDS Program Database
|
||||
/// </summary>
|
||||
/// <param name="data">Data to parse into a database</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>A filled RSDS Program Database on success, null on error</returns>
|
||||
public static RSDSProgramDatabase? AsRSDSProgramDatabase(this byte[]? data, ref int offset)
|
||||
{
|
||||
// If we have data that's invalid, we can't do anything
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
var rsdsProgramDatabase = new RSDSProgramDatabase();
|
||||
|
||||
rsdsProgramDatabase.Signature = data.ReadUInt32(ref offset);
|
||||
if (rsdsProgramDatabase.Signature != 0x53445352)
|
||||
return null;
|
||||
|
||||
var guid = data.ReadBytes(ref offset, 0x10);
|
||||
if (guid != null)
|
||||
rsdsProgramDatabase.GUID = new Guid(guid);
|
||||
rsdsProgramDatabase.Age = data.ReadUInt32(ref offset);
|
||||
rsdsProgramDatabase.PathAndFileName = data.ReadString(ref offset, Encoding.ASCII); // TODO: Actually null-terminated UTF-8
|
||||
|
||||
return rsdsProgramDatabase;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Implement other resource types from https://learn.microsoft.com/en-us/windows/win32/menurc/resource-file-formats
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class AACS : IFileSerializer<Models.AACS.MediaKeyBlock>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.AACS.MediaKeyBlock? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return new Streams.AACS().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class AACS : IFileSerializer<Models.AACS.MediaKeyBlock>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Serialize(Models.AACS.MediaKeyBlock? obj, string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
||||
using var stream = new Streams.AACS().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 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,15 +0,0 @@
|
||||
using SabreTools.Models.AttractMode;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class AttractMode : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public MetadataFile? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return new Streams.AttractMode().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.AttractMode;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class AttractMode : IFileSerializer<MetadataFile>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Serialize(MetadataFile? obj, string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
||||
using var stream = new Streams.AttractMode().Serialize(obj);
|
||||
if (stream == null)
|
||||
return false;
|
||||
|
||||
using var fs = File.OpenWrite(path);
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class BDPlus : IFileSerializer<Models.BDPlus.SVM>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.BDPlus.SVM? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return new Streams.BDPlus().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class BDPlus : IFileSerializer<Models.BDPlus.SVM>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Serialize(Models.BDPlus.SVM? obj, string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
||||
using var stream = new Streams.BDPlus().Serialize(obj);
|
||||
if (stream == null)
|
||||
return false;
|
||||
|
||||
using var fs = System.IO.File.OpenWrite(path);
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class BFPK : IFileSerializer<Models.BFPK.Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.BFPK.Archive? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return new Streams.BFPK().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class BFPK : IFileSerializer<Models.BFPK.Archive>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Serialize(Models.BFPK.Archive? obj, string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
||||
using var stream = new Streams.BFPK().Serialize(obj);
|
||||
if (stream == null)
|
||||
return false;
|
||||
|
||||
using var fs = System.IO.File.OpenWrite(path);
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class BSP : IFileSerializer<Models.BSP.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.BSP.File? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return new Streams.BSP().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class BSP : IFileSerializer<Models.BSP.File>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Serialize(Models.BSP.File? obj, string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
||||
using var stream = new Streams.BSP().Serialize(obj);
|
||||
if (stream == null)
|
||||
return false;
|
||||
|
||||
using var fs = System.IO.File.OpenWrite(path);
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class CFB : IFileSerializer<Models.CFB.Binary>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.CFB.Binary? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return new Streams.CFB().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class CFB : IFileSerializer<Models.CFB.Binary>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Serialize(Models.CFB.Binary? obj, string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
||||
using var stream = new Streams.CFB().Serialize(obj);
|
||||
if (stream == null)
|
||||
return false;
|
||||
|
||||
using var fs = System.IO.File.OpenWrite(path);
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class CIA : IFileSerializer<Models.N3DS.CIA>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Models.N3DS.CIA? Deserialize(string? path)
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return new Streams.CIA().Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class CIA : IFileSerializer<Models.N3DS.CIA>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Serialize(Models.N3DS.CIA? obj, string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
||||
using var stream = new Streams.CIA().Serialize(obj);
|
||||
if (stream == null)
|
||||
return false;
|
||||
|
||||
using var fs = System.IO.File.OpenWrite(path);
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using System.Text;
|
||||
|
||||
namespace SabreTools.Serialization.Files
|
||||
{
|
||||
public partial class Catalog : JsonFile<Models.Xbox.Catalog>
|
||||
{
|
||||
// Catalog.js file is a UTF-16 LE JSON
|
||||
public new Models.Xbox.Catalog? Deserialize(string? path)
|
||||
=> Deserialize(path, new UnicodeEncoding());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user