Frame Serialization

Aug 29, 2012 at 8:02 PM

Is it possible to decorate all frames with the SelizableAttribute to make it Clipboard frendly?

Coordinator
Aug 29, 2012 at 9:32 PM

Hi Massimiliano,

Unfortunately I can't add the serializable attribute to the frames because the ID3 project is a portable class library, and the serializable attribute is not supported.

Can you give me an idea of how you'd use these classes for the clipboard? It is possible to serialize the frames using the DataContractSerializer... would this be of any help?

If you really need the serializable attribute, it would be possible to create a non-portable version of the ID3 project and use conditional directives to add the attribute,

Regards,

Jeevan

Aug 29, 2012 at 9:45 PM
Edited Aug 29, 2012 at 9:46 PM

Hi Jeevan,

Thanks for the quick response, i've forgot that this is a Portable class library... Anyway i have implemented a class which wraps a PictureFrame and because of PictureFrame is not decorated with Serializable attribute, i cannot use the Clipboard class.

I have to investigate if DataContractSerializer could be of help.

Regards Massimiliano

Aug 29, 2012 at 11:08 PM

Hi Jeevan,

Using DataConstractSerializer i was able to Copy and Paste with clipboard with following steps:

1) Serialize your instance with DataContractSerializer to a MemoryStream

2) Read the stream bytes to a byte array

3) Copy and Paste the byte array to clipboard

4) Create a new MemoryStream with pasted byte array

5) Deserialize the object from the MemoryStream with the DataContractSerializer

A little bit long, but worked.

Regards Massimiliano