mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Let exceptions boil up
This commit is contained in:
@@ -6,55 +6,55 @@ namespace SabreTools.Models.SeparatedValue
|
||||
public class Row
|
||||
{
|
||||
/// <remarks>File Name</remarks>
|
||||
public string FileName { get; set; }
|
||||
public string? FileName { get; set; }
|
||||
|
||||
/// <remarks>Internal Name</remarks>
|
||||
public string InternalName { get; set; }
|
||||
public string? InternalName { get; set; }
|
||||
|
||||
/// <remarks>Description</remarks>
|
||||
public string Description { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <remarks>Game Name</remarks>
|
||||
public string GameName { get; set; }
|
||||
|
||||
/// <remarks>Game Description</remarks>
|
||||
public string GameDescription { get; set; }
|
||||
public string? GameDescription { get; set; }
|
||||
|
||||
/// <remarks>Type</remarks>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <remarks>Rom Name</remarks>
|
||||
public string RomName { get; set; }
|
||||
public string? RomName { get; set; }
|
||||
|
||||
/// <remarks>Disk Name</remarks>
|
||||
public string DiskName { get; set; }
|
||||
public string? DiskName { get; set; }
|
||||
|
||||
/// <remarks>Size, Numeric</remarks>
|
||||
public string Size { get; set; }
|
||||
public string? Size { get; set; }
|
||||
|
||||
/// <remarks>CRC</remarks>
|
||||
public string CRC { get; set; }
|
||||
public string? CRC { get; set; }
|
||||
|
||||
/// <remarks>MD5</remarks>
|
||||
public string MD5 { get; set; }
|
||||
public string? MD5 { get; set; }
|
||||
|
||||
/// <remarks>SHA1</remarks>
|
||||
public string SHA1 { get; set; }
|
||||
public string? SHA1 { get; set; }
|
||||
|
||||
/// <remarks>SHA256</remarks>
|
||||
public string SHA256 { get; set; }
|
||||
public string? SHA256 { get; set; }
|
||||
|
||||
/// <remarks>SHA384, Optional</remarks>
|
||||
public string SHA384 { get; set; }
|
||||
public string? SHA384 { get; set; }
|
||||
|
||||
/// <remarks>SHA512, Optional</remarks>
|
||||
public string SHA512 { get; set; }
|
||||
public string? SHA512 { get; set; }
|
||||
|
||||
/// <remarks>SpamSum, Optional</remarks>
|
||||
public string SpamSum { get; set; }
|
||||
public string? SpamSum { get; set; }
|
||||
|
||||
/// <remarks>Status, Nodump</remarks>
|
||||
public string Status { get; set; }
|
||||
public string? Status { get; set; }
|
||||
|
||||
#region DO NOT USE IN PRODUCTION
|
||||
|
||||
|
||||
@@ -18,18 +18,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="path">Path to the file to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return Deserialize(stream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes an AttractMode romlist in a stream to the defined type
|
||||
@@ -37,8 +29,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="stream">Stream to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(Stream? stream)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the stream is null
|
||||
if (stream == null)
|
||||
@@ -130,11 +120,5 @@ namespace SabreTools.Serialization
|
||||
dat.Row = rows.ToArray();
|
||||
return dat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="path">Path to the file to serialize to</param>
|
||||
/// <returns>True on successful serialization, false otherwise</returns>
|
||||
public static bool SerializeToFile(MetadataFile? metadataFile, string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = SerializeToStream(metadataFile);
|
||||
if (stream == null)
|
||||
@@ -30,12 +28,6 @@ namespace SabreTools.Serialization
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the defined type to a stream
|
||||
@@ -43,8 +35,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="metadataFile">Data to serialize</param>
|
||||
/// <returns>Stream containing serialized data on success, null otherwise</returns>
|
||||
public static Stream? SerializeToStream(MetadataFile? metadataFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the metadata file is null
|
||||
if (metadataFile == null)
|
||||
@@ -52,7 +42,12 @@ namespace SabreTools.Serialization
|
||||
|
||||
// Setup the writer and output
|
||||
var stream = new MemoryStream();
|
||||
var writer = new SeparatedValueWriter(stream, Encoding.UTF8) { Separator = ';', Quotes = false };
|
||||
var writer = new SeparatedValueWriter(stream, Encoding.UTF8)
|
||||
{
|
||||
Separator = ';',
|
||||
Quotes = false,
|
||||
VerifyFieldCount = false,
|
||||
};
|
||||
|
||||
// TODO: Include flag to write out long or short header
|
||||
// Write the short header
|
||||
@@ -64,12 +59,6 @@ namespace SabreTools.Serialization
|
||||
// Return the stream
|
||||
return stream;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write rows information to the current writer
|
||||
@@ -85,7 +74,7 @@ namespace SabreTools.Serialization
|
||||
// Loop through and write out the rows
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var rowArray = new string[]
|
||||
var rowArray = new string?[]
|
||||
{
|
||||
row.Name,
|
||||
row.Title,
|
||||
|
||||
@@ -18,18 +18,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="quotes">Enable quotes on read, false otherwise</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(string path, bool quotes)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return Deserialize(stream, quotes);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes a ClrMamePro metadata file in a stream to the defined type
|
||||
@@ -38,8 +30,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="quotes">Enable quotes on read, false otherwise</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(Stream? stream, bool quotes)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the stream is null
|
||||
if (stream == null)
|
||||
@@ -333,12 +323,6 @@ namespace SabreTools.Serialization
|
||||
dat.ADDITIONAL_ELEMENTS = additional.ToArray();
|
||||
return dat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Release object from the current reader context
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="quotes">Enable quotes on write, false otherwise</param>
|
||||
/// <returns>True on successful serialization, false otherwise</returns>
|
||||
public static bool SerializeToFile(MetadataFile? metadataFile, string path, bool quotes)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = SerializeToStream(metadataFile, quotes);
|
||||
if (stream == null)
|
||||
@@ -31,12 +29,6 @@ namespace SabreTools.Serialization
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the defined type to a stream
|
||||
@@ -45,8 +37,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="quotes">Enable quotes on write, false otherwise</param>
|
||||
/// <returns>Stream containing serialized data on success, null otherwise</returns>
|
||||
public static Stream? SerializeToStream(MetadataFile? metadataFile, bool quotes)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the metadata file is null
|
||||
if (metadataFile == null)
|
||||
@@ -65,12 +55,6 @@ namespace SabreTools.Serialization
|
||||
// Return the stream
|
||||
return stream;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write header information to the current writer
|
||||
|
||||
@@ -18,18 +18,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="path">Path to the file to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return Deserialize(stream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes an Everdrive SMDB in a stream to the defined type
|
||||
@@ -37,8 +29,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="stream">Stream to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(Stream? stream)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the stream is null
|
||||
if (stream == null)
|
||||
@@ -86,11 +76,5 @@ namespace SabreTools.Serialization
|
||||
dat.Row = rows.ToArray();
|
||||
return dat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="path">Path to the file to serialize to</param>
|
||||
/// <returns>True on successful serialization, false otherwise</returns>
|
||||
public static bool SerializeToFile(MetadataFile? metadataFile, string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = SerializeToStream(metadataFile);
|
||||
if (stream == null)
|
||||
@@ -31,12 +29,6 @@ namespace SabreTools.Serialization
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the defined type to a stream
|
||||
@@ -44,8 +36,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="metadataFile">Data to serialize</param>
|
||||
/// <returns>Stream containing serialized data on success, null otherwise</returns>
|
||||
public static Stream? SerializeToStream(MetadataFile? metadataFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the metadata file is null
|
||||
if (metadataFile == null)
|
||||
@@ -61,12 +51,6 @@ namespace SabreTools.Serialization
|
||||
// Return the stream
|
||||
return stream;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write rows information to the current writer
|
||||
|
||||
@@ -18,18 +18,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="hash">Hash corresponding to the hashfile variant</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static Models.Hashfile.Hashfile? Deserialize(string path, Hash hash)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return Deserialize(stream, hash);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes a hashfile variant in a stream to the defined type
|
||||
@@ -38,8 +30,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="hash">Hash corresponding to the hashfile variant</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static Models.Hashfile.Hashfile? Deserialize(Stream? stream, Hash hash)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the stream is null
|
||||
if (stream == null)
|
||||
@@ -150,11 +140,5 @@ namespace SabreTools.Serialization
|
||||
dat.ADDITIONAL_ELEMENTS = additional.ToArray();
|
||||
return dat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="hash">Hash corresponding to the hashfile variant</param>
|
||||
/// <returns>True on successful serialization, false otherwise</returns>
|
||||
public static bool SerializeToFile(Models.Hashfile.Hashfile? hashfile, string path, Hash hash)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = SerializeToStream(hashfile, hash);
|
||||
if (stream == null)
|
||||
@@ -33,12 +31,6 @@ namespace SabreTools.Serialization
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the defined type to a stream
|
||||
@@ -47,8 +39,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="hash">Hash corresponding to the hashfile variant</param>
|
||||
/// <returns>Stream containing serialized data on success, null otherwise</returns>
|
||||
public static Stream? SerializeToStream(Models.Hashfile.Hashfile? hashfile, Hash hash)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the metadata file is null
|
||||
if (hashfile == null)
|
||||
@@ -56,7 +46,12 @@ namespace SabreTools.Serialization
|
||||
|
||||
// Setup the writer and output
|
||||
var stream = new MemoryStream();
|
||||
var writer = new SeparatedValueWriter(stream, Encoding.UTF8) { Separator = ' ', Quotes = false };
|
||||
var writer = new SeparatedValueWriter(stream, Encoding.UTF8)
|
||||
{
|
||||
Separator = ' ',
|
||||
Quotes = false,
|
||||
VerifyFieldCount = false,
|
||||
};
|
||||
|
||||
// Write out the items, if they exist
|
||||
switch (hash)
|
||||
@@ -89,12 +84,6 @@ namespace SabreTools.Serialization
|
||||
// Return the stream
|
||||
return stream;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write SFV information to the current writer
|
||||
|
||||
@@ -17,18 +17,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="path">Path to the file to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return Deserialize(stream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes a MAME listrom file in a stream to the defined type
|
||||
@@ -36,8 +28,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="stream">Stream to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(Stream? stream)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the stream is null
|
||||
if (stream == null)
|
||||
@@ -187,11 +177,5 @@ namespace SabreTools.Serialization
|
||||
dat.ADDITIONAL_ELEMENTS = additional.ToArray();
|
||||
return dat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,18 +18,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="path">Path to the file to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return Deserialize(stream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes a RomCenter INI file in a stream to the defined type
|
||||
@@ -37,8 +29,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="stream">Stream to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(Stream? stream)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the stream is null
|
||||
if (stream == null)
|
||||
@@ -230,11 +220,5 @@ namespace SabreTools.Serialization
|
||||
}
|
||||
return dat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,18 +19,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="delim">Character delimiter between values</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(string path, char delim)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return Deserialize(stream, delim);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes a separated-value variant in a stream to the defined type
|
||||
@@ -39,8 +31,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="delim">Character delimiter between values</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static MetadataFile? Deserialize(Stream? stream, char delim)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the stream is null
|
||||
if (stream == null)
|
||||
@@ -129,11 +119,5 @@ namespace SabreTools.Serialization
|
||||
dat.Row = rows.ToArray();
|
||||
return dat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="delim">Character delimiter between values</param>
|
||||
/// <returns>True on successful serialization, false otherwise</returns>
|
||||
public static bool SerializeToFile(MetadataFile? metadataFile, string path, char delim)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = SerializeToStream(metadataFile, delim);
|
||||
if (stream == null)
|
||||
@@ -31,12 +29,6 @@ namespace SabreTools.Serialization
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the defined type to a stream
|
||||
@@ -45,8 +37,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="delim">Character delimiter between values</param>
|
||||
/// <returns>Stream containing serialized data on success, null otherwise</returns>
|
||||
public static Stream? SerializeToStream(MetadataFile? metadataFile, char delim)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the metadata file is null
|
||||
if (metadataFile == null)
|
||||
@@ -66,12 +56,6 @@ namespace SabreTools.Serialization
|
||||
// Return the stream
|
||||
return stream;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write header information to the current writer
|
||||
@@ -79,7 +63,7 @@ namespace SabreTools.Serialization
|
||||
/// <param name="writer">SeparatedValueWriter representing the output</param>
|
||||
private static void WriteHeader(SeparatedValueWriter writer)
|
||||
{
|
||||
var headerArray = new string[]
|
||||
var headerArray = new string?[]
|
||||
{
|
||||
"File Name",
|
||||
"Internal Name",
|
||||
@@ -118,7 +102,7 @@ namespace SabreTools.Serialization
|
||||
// Loop through and write out the rows
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var rowArray = new string[]
|
||||
var rowArray = new string?[]
|
||||
{
|
||||
row.FileName,
|
||||
row.InternalName,
|
||||
|
||||
@@ -15,18 +15,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="path">Path to the file to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static T? Deserialize(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = PathProcessor.OpenStream(path);
|
||||
return Deserialize(stream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes an XML file in a stream to the defined type
|
||||
@@ -34,8 +26,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="stream">Stream to deserialize</param>
|
||||
/// <returns>Deserialized data on success, null on failure</returns>
|
||||
public static T? Deserialize(Stream? stream)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the stream is null
|
||||
if (stream == null)
|
||||
@@ -54,11 +44,5 @@ namespace SabreTools.Serialization
|
||||
// Perform the deserialization and return
|
||||
return (T?)serializer.Deserialize(xmlReader);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="path">Path to the file to serialize to</param>
|
||||
/// <returns>True on successful serialization, false otherwise</returns>
|
||||
public static bool SerializeToFile(T? obj, string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = SerializeToStream(obj);
|
||||
if (stream == null)
|
||||
@@ -27,12 +25,6 @@ namespace SabreTools.Serialization
|
||||
stream.CopyTo(fs);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the defined type to a stream
|
||||
@@ -40,8 +32,6 @@ namespace SabreTools.Serialization
|
||||
/// <param name="obj">Data to serialize</param>
|
||||
/// <returns>Stream containing serialized data on success, null otherwise</returns>
|
||||
public static Stream? SerializeToStream(T? obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If the object is null
|
||||
if (obj == null)
|
||||
@@ -61,11 +51,5 @@ namespace SabreTools.Serialization
|
||||
serializer.Serialize(xmlWriter, obj);
|
||||
return stream;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Handle logging the exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user