daily update on 20240419 by nitload youmu, SSD merged into main stream
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Data
|
||||
{
|
||||
|
||||
public abstract class SSDSerializable
|
||||
{
|
||||
public abstract byte SSDTypeCode { get; }
|
||||
|
||||
public abstract byte[] GetBytes();
|
||||
|
||||
public abstract byte[] GetBytes(out int length);
|
||||
|
||||
internal abstract void BuildFromByteStream(byte[] stream);
|
||||
}
|
||||
|
||||
public class SerializableTypeCode
|
||||
{
|
||||
public const byte IndexTable = 1;
|
||||
public const byte Image = 2;
|
||||
public const byte Audio = 3;
|
||||
public const byte Shader = 4;
|
||||
public const byte Text = 5;
|
||||
public const byte RawData = 6;
|
||||
public const byte VirtualFolder = 7;
|
||||
}
|
||||
|
||||
public static partial class Serializer
|
||||
{
|
||||
public static byte[] Serialize(SSDSerializable serializableObject)
|
||||
{
|
||||
return serializableObject.GetBytes();
|
||||
}
|
||||
|
||||
public static T Deserialize<T>(byte[] stream)where T : SSDSerializable
|
||||
{
|
||||
T serializableObject = (T)Activator.CreateInstance<T>();
|
||||
serializableObject.BuildFromByteStream(stream);
|
||||
return serializableObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user