Add file serializers for executable types

This commit is contained in:
Matt Nadareski
2024-04-02 12:06:56 -04:00
parent 27d36a11ca
commit 822839c813
8 changed files with 152 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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