Files
SabreTools.Serialization/Files/SeparatedValue.Serializer.cs

26 lines
789 B
C#
Raw Permalink Normal View History

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