using System.IO;
namespace OCES.Haptic
{
public interface IBinarySerializable
{
void DeSerialize(BinaryReader reader);
void Serialize(BinaryWriter writer);
}
public enum HapticType
{
Preset = 0, //播放预制
Emphasis = 1, //播放瞬时
Constant = 2, //播放连续
Advance = 3, //播放文件
}
///
/// 文件操作类
///
public static class FileManager
{
///
/// 从内存流中读取二进制
///
///
///
///
public static bool ReadBinaryDataFromBytes(byte[] bytes, ref IBinarySerializable data)
{
if (bytes == null)
return false;
using MemoryStream memoryStream = new(bytes);
using (BinaryReader br = new(memoryStream))
{
data.DeSerialize(br);
}
memoryStream.Close();
return true;
}
}
}