2023-09-09 01:41:49 -04:00
|
|
|
using SabreTools.Models.SeparatedValue;
|
2023-09-15 22:34:47 -04:00
|
|
|
using SabreTools.Serialization.Interfaces;
|
2023-09-09 01:41:49 -04:00
|
|
|
|
|
|
|
|
namespace SabreTools.Serialization.Files
|
|
|
|
|
{
|
|
|
|
|
public partial class SeparatedValue : IFileSerializer<MetadataFile>
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
#if NET48
|
2023-09-11 01:23:29 -04:00
|
|
|
public bool Serialize(MetadataFile obj, string path) => Serialize(obj, path, ',');
|
2023-09-09 01:41:49 -04:00
|
|
|
#else
|
2023-09-11 01:23:29 -04:00
|
|
|
public bool Serialize(MetadataFile? obj, string? path) => Serialize(obj, path, ',');
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
#if NET48
|
|
|
|
|
public bool Serialize(MetadataFile obj, string path, char delim)
|
|
|
|
|
#else
|
|
|
|
|
public bool Serialize(MetadataFile? obj, string? path, char delim)
|
2023-09-09 01:41:49 -04:00
|
|
|
#endif
|
|
|
|
|
{
|
2023-09-10 17:32:03 -04:00
|
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
|
|
|
return false;
|
|
|
|
|
|
2023-09-11 01:23:29 -04:00
|
|
|
using (var stream = new Streams.SeparatedValue().Serialize(obj, delim))
|
2023-09-09 01:41:49 -04:00
|
|
|
{
|
|
|
|
|
if (stream == null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
using (var fs = System.IO.File.OpenWrite(path))
|
|
|
|
|
{
|
|
|
|
|
stream.CopyTo(fs);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|