Use new static stream serializer

This commit is contained in:
Matt Nadareski
2024-04-03 15:50:06 -04:00
parent b6fe94116b
commit c19a4a94f4
44 changed files with 44 additions and 44 deletions

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.AACS().Serialize(obj);
using var stream = Streams.AACS.Serialize(obj);
if (stream == null)
return false;

View File

@@ -18,7 +18,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.AttractMode().SerializeImpl(obj);
using var stream = Streams.AttractMode.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.BDPlus().SerializeImpl(obj);
using var stream = Streams.BDPlus.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.BFPK().SerializeImpl(obj);
using var stream = Streams.BFPK.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.BSP().SerializeImpl(obj);
using var stream = Streams.BSP.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.CFB().SerializeImpl(obj);
using var stream = Streams.CFB.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.CIA().SerializeImpl(obj);
using var stream = Streams.CIA.Serialize(obj);
if (stream == null)
return false;

View File

@@ -29,7 +29,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.ClrMamePro().Serialize(obj, quotes);
using var stream = Streams.ClrMamePro.Serialize(obj, quotes);
if (stream == null)
return false;

View File

@@ -18,7 +18,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.CueSheet().SerializeImpl(obj);
using var stream = Streams.CueSheet.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.DosCenter().SerializeImpl(obj);
using var stream = Streams.DosCenter.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.EverdriveSMDB().SerializeImpl(obj);
using var stream = Streams.EverdriveSMDB.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.GCF().SerializeImpl(obj);
using var stream = Streams.GCF.Serialize(obj);
if (stream == null)
return false;

View File

@@ -28,7 +28,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.Hashfile().Serialize(obj, hash);
using var stream = Streams.Hashfile.Serialize(obj, hash);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.IRD().SerializeImpl(obj);
using var stream = Streams.IRD.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.InstallShieldCabinet().SerializeImpl(obj);
using var stream = Streams.InstallShieldCabinet.Serialize(obj);
if (stream == null)
return false;

View File

@@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Files
public T? DeserializeImpl(string? path, Encoding encoding)
{
using var data = PathProcessor.OpenStream(path);
return Streams.JsonFile<T>.Deserialize(data, encoding);
return new Streams.JsonFile<T>().DeserializeImpl(data, encoding);
}
}
}

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.LinearExecutable().SerializeImpl(obj);
using var stream = Streams.LinearExecutable.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.Listrom().SerializeImpl(obj);
using var stream = Streams.Listrom.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.MSDOS().SerializeImpl(obj);
using var stream = Streams.MSDOS.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.MicrosoftCabinet().SerializeImpl(obj);
using var stream = Streams.MicrosoftCabinet.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.MoPaQ().SerializeImpl(obj);
using var stream = Streams.MoPaQ.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.N3DS().SerializeImpl(obj);
using var stream = Streams.N3DS.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.NCF().SerializeImpl(obj);
using var stream = Streams.NCF.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.NewExecutable().SerializeImpl(obj);
using var stream = Streams.NewExecutable.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.Nitro().SerializeImpl(obj);
using var stream = Streams.Nitro.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.PAK().SerializeImpl(obj);
using var stream = Streams.PAK.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.PFF().SerializeImpl(obj);
using var stream = Streams.PFF.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.PIC().SerializeImpl(obj);
using var stream = Streams.PIC.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.PlayJAudio().SerializeImpl(obj);
using var stream = Streams.PlayJAudio.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.PlayJPlaylist().SerializeImpl(obj);
using var stream = Streams.PlayJPlaylist.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.PortableExecutable().SerializeImpl(obj);
using var stream = Streams.PortableExecutable.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.Quantum().SerializeImpl(obj);
using var stream = Streams.Quantum.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.RomCenter().SerializeImpl(obj);
using var stream = Streams.RomCenter.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.SGA().SerializeImpl(obj);
using var stream = Streams.SGA.Serialize(obj);
if (stream == null)
return false;

View File

@@ -26,7 +26,7 @@ namespace SabreTools.Serialization.Files
public Models.SeparatedValue.MetadataFile? DeserializeImpl(string? path, char delim)
{
using var stream = PathProcessor.OpenStream(path);
return new Streams.SeparatedValue().Deserialize(stream, delim);
return Streams.SeparatedValue.Deserialize(stream, delim);
}
}
}

View File

@@ -28,7 +28,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.SeparatedValue().SerializeImpl(obj, delim);
using var stream = Streams.SeparatedValue.Serialize(obj, delim);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.VBSP().SerializeImpl(obj);
using var stream = Streams.VBSP.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.VPK().SerializeImpl(obj);
using var stream = Streams.VPK.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.WAD().SerializeImpl(obj);
using var stream = Streams.WAD.Serialize(obj);
if (stream == null)
return false;

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.Files
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.XZP().SerializeImpl(obj);
using var stream = Streams.XZP.Serialize(obj);
if (stream == null)
return false;

View File

@@ -12,7 +12,7 @@ namespace SabreTools.Serialization.Files
public T? DeserializeImpl(string? path)
{
using var data = PathProcessor.OpenStream(path);
return Streams.XmlFile<T>.Deserialize(data);
return new Streams.XmlFile<T>().DeserializeImpl(data);
}
}
}

View File

@@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Files
/// <param name="sysid">Optional DOCTYPE sysid</param>
/// <param name="subset">Optional DOCTYPE name</param>
/// <returns>True on successful serialization, false otherwise</returns>
protected bool SerializeImpl(T? obj, string? path, string? name = null, string? pubid = null, string? sysid = null, string? subset = null)
public bool SerializeImpl(T? obj, string? path, string? name = null, string? pubid = null, string? sysid = null, string? subset = null)
{
if (string.IsNullOrEmpty(path))
return false;

View File

@@ -52,7 +52,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.Deserialize(data, currentOffset);
if (entryHeader == null)
return null;

View File

@@ -29,7 +29,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="sysid">Optional DOCTYPE sysid</param>
/// <param name="subset">Optional DOCTYPE name</param>
/// <returns>Stream containing serialized data on success, null otherwise</returns>
protected Stream? SerializeImpl(T? obj, string? name = null, string? pubid = null, string? sysid = null, string? subset = null)
public Stream? SerializeImpl(T? obj, string? name = null, string? pubid = null, string? sysid = null, string? subset = null)
{
// If the object is null
if (obj == null)