mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-24 15:55:05 +00:00
Add file serializers for executable types
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
SabreTools.Serialization/Files/MSDOS.Deserializer.cs
Normal file
16
SabreTools.Serialization/Files/MSDOS.Deserializer.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
SabreTools.Serialization/Files/MSDOS.Serializer.cs
Normal file
22
SabreTools.Serialization/Files/MSDOS.Serializer.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
SabreTools.Serialization/Files/NewExecutable.Deserializer.cs
Normal file
16
SabreTools.Serialization/Files/NewExecutable.Deserializer.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
SabreTools.Serialization/Files/NewExecutable.Serializer.cs
Normal file
22
SabreTools.Serialization/Files/NewExecutable.Serializer.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user