Serialize&Deserialize Composite objects

  • Thread starter Thread starter Gianmaria
  • Start date Start date
G

Gianmaria

Hi,
how do i deserialize a composite object

my object have this structure...

obj
|_ leaf
|_subObj
|_leaf

and so on.. everything ok when i serialize (i'm using bin formatting), but
when i deserialize...

i have a costructor for desialization like this...

public Ghost(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
{
this.leaf = info.GetValue("Leaf")
}

Do i have to use info.GetValue during deserializaion????



Regards,

Gianmaria
 
Hi

I'm affraid that method "GetValue" needs the Type of
returned object. And if your "leaf" variable type is
other than "object" you should provide a type casting.

e.g.

this.leaf = (LeafType) info.GetValue("Leaf"
, typeof(LeafType));

I'm not sure, but it should work if you replace
LeafType with its interface (then leaf variable should
be that interface too).

Regards

Marcin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top