Serialization problem
-
I'm trying to binary serialize a 2D array using [Serializable] and ISerializable. In Special constructor for deserialization, I can't deserialize my array. I don't know what the type in
info->GetValue("something", ??Type::typeid)
. This is my code :[Serializable]
private ref class SerializedArrayClass : public ISerializable
{
public:
array<array<float>^>^ jaggedArray;
array<float, 2>^ genericArray;
// Matrix is my other class
Matrix^ matrixArray;int width; int height; int nElement; // Constructor SerializedArrayClass(int width, int height) { this->width = width; this->height = height; } // Init those 3 arrays InitArray() { // ... }
protected:
// Special Constructor for deserialize
SerializedArrayClass(SerializationInfo^ info, StreamingContext context)
{
this->width = safe_cast<int>(info->GetValue("width", int::typeid));
this->height = safe_cast<int>(info->GetValue("height", int::typeid));// this is where the problems begin this->jaggedArray = safe\_cast<array<array<float>^>^>>(info->GetValue("jaggedArray", ??::typeid)); this->genericArray = safe\_cast<array<float, 2>^>>(info->GetValue("genericArray", ??::typeid)); this->matrixArray = safe\_cast<Matrix^>(info->GetValue("matrixArray", ??::typeid)); }
public:
// For serialize
virtual void GetObjectData(SerializationInfo^ info, StreamingContext context)
{
info->AddValue("width", this->width);
info->AddValue("height", this->height);
info->AddValue("jaggedArray", this->jaggedArray);
info->AddValue("genericArray", this->genericArray);
info->AddValue("matrixArray", this->matrixArray);
}
}What is the correct Type for 2D array and Matrix object? Thanks,