daily update on 20240419 by nitload youmu, SSD merged into main stream

This commit is contained in:
YoumuLiu
2024-04-20 02:36:36 +08:00
parent efeb4ba058
commit 7b67eb2f4d
81 changed files with 4568 additions and 33 deletions
@@ -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;
}
}
}