mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-11 03:17:11 +00:00
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using SabreTools.Serialization.Interfaces;
|
|
|
|
namespace SabreTools.Serialization.Files
|
|
{
|
|
public partial class SeparatedValue : IFileSerializer<Models.SeparatedValue.MetadataFile>
|
|
{
|
|
/// <inheritdoc cref="IFileSerializer.SerializeImpl(T?, string?)"/>
|
|
public static bool Serialize(Models.SeparatedValue.MetadataFile? obj, string? path)
|
|
{
|
|
var serializer = new SeparatedValue();
|
|
return serializer.SerializeImpl(obj, path);
|
|
}
|
|
|
|
/// <inheritdoc cref="IFileSerializer.SerializeImpl(T?, string?)"/>
|
|
public static bool Serialize(Models.SeparatedValue.MetadataFile? obj, string? path, char delim)
|
|
{
|
|
var serializer = new SeparatedValue();
|
|
return serializer.SerializeImpl(obj, path, delim);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public bool SerializeImpl(Models.SeparatedValue.MetadataFile? obj, string? path)
|
|
=> SerializeImpl(obj, path, ',');
|
|
|
|
/// <inheritdoc/>
|
|
public bool SerializeImpl(Models.SeparatedValue.MetadataFile? obj, string? path, char delim)
|
|
{
|
|
if (string.IsNullOrEmpty(path))
|
|
return false;
|
|
|
|
using var stream = Streams.SeparatedValue.Serialize(obj, delim);
|
|
if (stream == null)
|
|
return false;
|
|
|
|
using var fs = System.IO.File.OpenWrite(path);
|
|
stream.CopyTo(fs);
|
|
return true;
|
|
}
|
|
}
|
|
} |