Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Serialization problem

Serialization problem

Scheduled Pinned Locked Moved Managed C++/CLI
questiondata-structuresjsonhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roshihans
    wrote on last edited by
    #1

    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,

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups