Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Serializing Cut/Copy and File Save (Read 2906 times)
maui26
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: May 13th, 2008
Serializing Cut/Copy and File Save
May 13th, 2008 at 8:08pm
Print Post  
I am currently evaluating the trial version.

I am getting the same following error when using CopyToClipboard, CutToClipboard, and SaveToFile:

Type 'Designer.SerializableDictionary`2[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[Designer.PropertyValue, Designer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' in Assembly 'Designer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

I have no problems with importing/exporting XML using LoadFromXml and SaveToXML after handling the DeserializeTag and SerializeTag events. (see posting http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=119616009...) - My ShapeNode tag objects are set to a serializable object that contains a SerializableDictionary object with a value that's a serializable object... - in otherwords, all my custom objects should be serializable.

I realize that I need to write a handler for SerializeControl and DeserializeControl, but do not know how to proceed. Could you please advise?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Serializing Cut/Copy and File Save
Reply #1 - May 14th, 2008 at 7:15am
Print Post  
Apart from implementing ISerializable, you should mark the tag classes with the [Serializabe] attribute. Have you done that?

Stoyan
  
Back to top
 
IP Logged
 
maui26
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: May 13th, 2008
Re: Serializing Cut/Copy and File Save
Reply #2 - May 14th, 2008 at 1:20pm
Print Post  
I guess the class I'm using is a bit out of the norm for serialization. In .NET the Dictionary class is not serializable, so I ended up creating an SerializableDictionary class that implements the IXMLSerializable interface (here's where I got the code:
http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx )  In this case, I did not need to mark my class with [Serializable()].

But I took your advice and went ahead and added the [Serializable()] marking to the SerializableDictionary class:
*****
[XmlRoot("dictionary")]
[Serializable()]
    public class SerializableDictionary<TKey, TValue>

       : Dictionary<TKey, TValue>, IXmlSerializable

    {...}
*****
and the result was this error:

Type 'MindFusion.Diagramming.Shape' in Assembly 'MindFusion.Diagramming, Version=5.0.3.20676, Culture=neutral, PublicKeyToken=a0d18338041985ba' is not marked as serializable.

It's definitely that Dictionary object that's making all the trouble. I'm thinking I might need to use another lookup/hash object to implement my logic.

Thanks for the quick response!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Serializing Cut/Copy and File Save
Reply #3 - May 14th, 2008 at 1:53pm
Print Post  
The Hashtable class is serializable, however it still won't work if you are storing Shape objects in the table, since we haven't marked the Shape class as serializable. It should be fine if you save Shape.Ids there instead of Shapes, and later use the Shape.FromId() method to get the corresponding shape.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
maui26
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: May 13th, 2008
Re: Serializing Cut/Copy and File Save
Reply #4 - May 14th, 2008 at 5:38pm
Print Post  
I just ended up writing my own event handlers to cut/copy/paste on selected ShapeNodes in the diagram.

Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint