mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-16 05:45:24 +00:00
32 lines
831 B
C#
32 lines
831 B
C#
using System.IO;
|
|
using SabreTools.Models.AttractMode;
|
|
using SabreTools.Serialization.Interfaces;
|
|
|
|
namespace SabreTools.Serialization.Files
|
|
{
|
|
public partial class AttractMode : IFileSerializer<MetadataFile>
|
|
{
|
|
/// <inheritdoc/>
|
|
#if NET48
|
|
public bool Serialize(MetadataFile obj, string path)
|
|
#else
|
|
public bool Serialize(MetadataFile? obj, string? path)
|
|
#endif
|
|
{
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
return false;
|
|
|
|
using (var stream = new Streams.AttractMode().Serialize(obj))
|
|
{
|
|
if (stream == null)
|
|
return false;
|
|
|
|
using (var fs = File.OpenWrite(path))
|
|
{
|
|
stream.CopyTo(fs);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |