Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic problem with serialize (Read 2546 times)
jackhuclan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Nov 17th, 2011
problem with serialize
Nov 17th, 2011 at 9:37am
Print Post  
I failed to serialize the DiagramNode when I use the tag property of the DiagramNode to bind a object which signed serializable and had an event ,I can serialize the object without event .so can you help me to find some way to serialize such object,or some way not to serialize the event?

[Serializable]
pubic class Sample()
{
     public string Name{get;set}
     public event EventHandler PropertyChanged;
     ......
}
DiagramNode node=new DiagramNode();
node.tag=new Sample();
.....

thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with serialize
Reply #1 - Nov 17th, 2011 at 9:40am
Print Post  
Do you mean there is an event handler attached to the tag object, and you need to attach it again after deserialization?
  
Back to top
 
IP Logged
 
jackhuclan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Nov 17th, 2011
Re: problem with serialize
Reply #2 - Nov 17th, 2011 at 12:10pm
Print Post  
Stoyo wrote on Nov 17th, 2011 at 9:40am:
Do you mean there is an event handler attached to the tag object, and you need to attach it again after deserialization?

I don't need to attach it again. Because I need to be notified when I modify the property of object referenced by the tag property.But once I added the event ,I can't serialize the DiagramNode itself.

thanks for you help.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with serialize
Reply #3 - Nov 17th, 2011 at 12:15pm
Print Post  
Does the built-in serialization throw any exception if there's an event handler attached? Or does it throw even if there's only the event declaration in the class without handlers attached to it? In the latter case you will have to implement custom serialization by handling the SerializeTag and DeserializeTag events. Otherwise, you could temporarily detach the event handlers before serialization, and attach them again afterwards.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint