1234567891011121314151617181920212223242526272829303132333435 |
- using System.IO;
- namespace TBL.CSharp.Serialization
- {
- /// <summary>
- /// 可使用 <see cref="Stream"/> 序列化的对象接口
- /// <para>便于各类 C# API 体系来使用</para>
- /// </summary>
- public interface IStreamSerializable
- {
- /// <summary>
- /// 序列化
- /// <para>应妥当地自行处理字节序兼容</para>
- /// </summary>
- /// <param name="stream">要序列化到的目标流</param>
- /// <param name="withEndianConversion">是否进行端序转换</param>
- /// <returns>序列化数据的字节数</returns>
- int Serialize(Stream stream, bool withEndianConversion);
- /// <summary>
- /// 反序列化
- /// <para>应妥当地自行处理字节序兼容</para>
- /// </summary>
- /// <param name="stream">要反序列化的来源流</param>
- /// <param name="withEndianConversion">是否进行端序转换</param>
- /// <returns>反序列化数据的字节数</returns>
- int Deserialize(Stream stream, bool withEndianConversion);
-
- /// <summary>
- /// 当此对象反序列化时,是否应该使用构造方法初始化
- /// <para>如果为否,反序列化时创建的对象将不会使用构造方法</para>
- /// </summary>
- bool IsShouldInitializeWhenDeserialize();
- }
- }
|