Files
SabreTools.Serialization/Bytes/GCF.Deserializer.cs
2023-09-08 21:58:44 -04:00

27 lines
779 B
C#

using System.IO;
namespace SabreTools.Serialization.Bytes
{
public partial class GCF : IByteSerializer<Models.GCF.File>
{
/// <inheritdoc/>
#if NET48
public Models.GCF.File Deserialize(byte[] data, int offset)
#else
public Models.GCF.File? Deserialize(byte[]? data, int offset)
#endif
{
// If the data is invalid
if (data == null)
return null;
// If the offset is out of bounds
if (offset < 0 || offset >= data.Length)
return null;
// Create a memory stream and parse that
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
return new Streams.GCF().Deserialize(dataStream);
}
}
}