this project implement some methods to serialize struct to binary format or deserialize struct from binary format.
Accept MemberIndex
attribute to a field to indicated the order when serializing the object. All the fileds and properties MUST have one index or you will get an exception.
Accept StructToRaw
attribute to a struct to indicated the serializer uses BigEndian or LittleEndian.
Accept MarshalAs
attribute to a field, you can:
UnmanagedType.ByValArray
andArraySubType
to a array field, will get trancation or padding when serializing. TypesI1,U1,I2,U2,I4,U4,I8,U8,R4,R8
are supported now.UnmanagedType
to a basic value field, will get trancation or padding when serializing. TypesI1,U1,I2,U2,I4,U4,I8,U8,R4,R8
are supported now.
Use RawBinaryFormatter
to serialize or deserialize.
- The type of property/field that have attribute
LengthTo
must belong
. You can useMarshalAs
to change the serialize/deserialize raw type. - We treated enum as int when serialize or deserialize.
In some case, there are half byte or bit data need to be transform. We need to specify some bits in a byte need to be assign to a property. In some case, we can't split buffer before get the length filed. So there is no method for Deserialize object array from buffer.